How to programmatically turn off quirks mode in IE8 WebBrowser control?

那年仲夏 提交于 2019-11-27 13:35:28

I think the issue you're facing is described in IEBlog: WebBrowser Control Rendering Modes in IE8:

While webmasters can easily alter their site to render properly in the new version of IE, many software vendors do not have the resources to instantly push out new versions of their applications with updated internal pages. In order to ensure that these existing applications remain in working order, IE8 renders pages running within instances of the WebBrowser control in IE7 Standards Mode by default.

Here I should note that the comments on the page say the above is incorrect, and that "IE8 renders pages running within instances of the WebBrowser control in IE7 Strict Mode OR Quirks mode by default, depending on the page's doctype."

The solution is as follows:

When an executable loads an instance of the WebBrowser control it scans the registry to check whether the executable wants IE7 Standards or IE8 Standards mode.

...

To run in IE8 Standards Mode insert the following registry value:

[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_NATIVE_DOCUMENT_MODE]

"MyApplication.exe"=dword:13880

In both of these instances, MyApplication.exe should be replaced with the name of the executable that will be running WebBrowser controls in a specified mode.

So it sounds like the "programmatic" solution is to write a key in the registry saying you want IE8 Standards mode for WebBrowser controls in your specific application.

Elijah

If you don't want to use the registry key technique, you could insert the following tag:

<meta http-equiv="X-UA-Compatible" content="IE=8" />

The "content" attribute forces rendering in various modes.

The last I heard was that IE8 would use standards mode by default. Are you seeing an actual problem with the latest beta version? Are you sure it's rendering in quirks mode to start with, without a user explicitly hitting the compatibility view button?

Please note there have been some changes since the beta, the registry keys have been renamed etc. Read more here.

Dirk Bester

This has actual code to programmatically do this and handles up to IE11 so far:

C# webbrowser Ajax call

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!