The WebBrowser control shipped with .NET 4.7 is throwing lots of JavaScript errors. For example, we tried with www.yahoo.com
and we get multiple JavaScript errors. One such example is shown below:
If we browse the same link in internet explorer 11, we are not getting any error and browsing session goes smooth. Note that we already set Browser Emulation registry setting for IE 11. Used the Link to Set IE 11 Emulation. The Registry Key for the Emulation is:
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION
(For 64 bit machine)
Re-production steps
- Create a Visual C# Windows Forms Application
- Place Web-Browser Control and a Command Button in the Form
Add the Following code in the command button Handler:
private void button1_Click(object sender, EventArgs e) { webBrowser1.Navigate("http://www.yahoo.com"); }
That is all. Once we click the command button, we have to respond to multiple JavaScript errors. How do we resolve this issue?
Note that we already have Browser Emulation for IE is set to 11 (in Registry). We do not want to suppress the Error, as we lose the service provided by the JavaScript. For example, click the “Cricket” button in the very top of the Yahoo page: