简体   繁体   中英

C# Web Browser Control - Make it Just Like IE

My WinForms project involves a C# web browser control - and I am getting the dreaded scripting error (like this image, different error though) when I visit different webpages:

脚本错误

I have read, and done , all the stuff about updating the browser emulation mode from IE7 to IE9 (or 11) in the windows registry (a la this stuff Use latest version of Internet Explorer in the webbrowser control ) and the error still persists.

Now this is really frustrating due to the fact the the web page I am visiting works fine in IE itself, it is just my embedded one that has the error.

In desperation, I renamed my generated exe file "iexplore.exe" and bingo, the app works, with no scripting errors .

So this tells me there must be other settings in the registry or somewhere that cause this error, if anyone knows what these are I'd be most grateful if you could share them please!

NB I don't want to suppress the errors, I want to run the script.

Set the WebBrowser.ScriptErrorsSuppressed property to true disable the alerts for errors. Documentation here .

You can also change the IE version used by your WebBrowser as seen here , though I recommend doing this in the installer as editing the registry requires admin permissions.

I would also recommend navigating to http://detectmybrowser.com/ from your WinForms browser to make sure that the changes you made to your registry are correct.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM