在WebBroswer控件中以标准模式查看页面

最近尝试用CSS3等一些新特性做一些页面,并在做了一些兼容处理之后,支持了IE7,但是碰到邪门的问题就是哪怕机器上的IE装的是非常新的10、11这样的版本,在使用WebBrowser查看页面时依旧会出现各种渲染和JS错误,甚至会出现崩溃的问题。比较残念的就是因为很早以前制作的桌面程序中正好使用WebBrowser 调用了这些新页面 √(─皿─)√

查阅MSDN时看到

Web browser control by default runs in compatibility mode unless you set the feature browser emulation registry key.
WebBrowser 控件默认运行在兼容性模式,除非修改注册表键值

于是我的心中真是无数的草泥马在奔腾啊

解决的方案是,在注册表

32位系统的:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION

64位系统的:HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION

新建一个DWORD键,
键名是你调用WebBrowser的exe的文件名
键值:

Value Description
11001 (0x2AF9 Internet Explorer 11. Webpages are displayed in IE11 edge mode, regardless of the !DOCTYPE directive.
11000 (0x2AF8) IE11. Webpages containing standards-based !DOCTYPE directives are displayed in IE11 edge mode. Default value for IE11.
10001 (0x2711) Internet Explorer 10. Webpages are displayed in IE10 Standards mode, regardless of the !DOCTYPE directive.
10000 (0x02710) Internet Explorer 10. Webpages containing standards-based !DOCTYPE directives are displayed in IE10 Standards mode. Default value for Internet Explorer 10.
9999 (0x270F) Windows Internet Explorer 9. Webpages are displayed in IE9 Standards mode, regardless of the !DOCTYPE directive.
9000 (0x2328) Internet Explorer 9. Webpages containing standards-based !DOCTYPE directives are displayed in IE9 mode. Default value for Internet Explorer 9.Important  In Internet Explorer 10, Webpages containing standards-based !DOCTYPE directives are displayed in IE10 Standards mode.
8888 (0x22B8) Webpages are displayed in IE8 Standards mode, regardless of the !DOCTYPE directive.
8000 (0x1F40) Webpages containing standards-based !DOCTYPE directives are displayed in IE8 mode. Default value for Internet Explorer 8Important  In Internet Explorer 10, Webpages containing standards-based !DOCTYPE directives are displayed in IE10 Standards mode.
7000 (0x1B58) Webpages containing standards-based !DOCTYPE directives are displayed in IE7 Standards mode. Default value for applications hosting the WebBrowser Control.

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注