改变Web Browser控件IE版本

时间:2023-03-09 03:34:06
改变Web Browser控件IE版本

默认的webbrowser控件使用的渲染模式版本似乎是IE7,想要更改更高版本,如下:

在注册表位置

HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION 的右侧新建一个DWORD值,名称为你主应用EXE的名称xxx.exe,值为0

  注意: 1、为什么用HKEY_CURRENT_USER,而不HKEY_LOCAL_MACHINE?因为在HKEY_CURRENT_USER下不区分32位 64位程序,两种都位于一处;而在HKEY_LOCAL_MACHINE下,32位程序在64位系统中需要到Wow6432Node分支下去注册。除此之外,在HKEY_LOCAL_MACHINE下注册需要管理员权限,管理员权限可不是管理员双击你的程序就能让程序直接获得的~~

      2、假设wb控件位于dll中,名称必须填调用该dll的EXE应用程序的名称,如xxx.exe。

      3、只填写exe应用程序的名称,不要填路径。这意味着程序同名冲突的可能,虽然可能性小。

值为0(似乎)将默认调用最新版本的IE模式渲染wb控件。注意(似乎),微软官方并没有具体文档说明,但经我本人测试(Win7 x64 IE11)以及外国用户的评论(见下方链接),工作正常。值(见下方列表)高于用户已安装的最高IE版本,也会产生同样效果。

      4、若你需要在Visual Studio中调试该程序,名称应为xxx.vshost.exe

  我编写的一个Windows Live Writer的插件XXX.dll使用了webbrowser控件,那么我应该填写的名称是WindowsLiveWriter.exe,而不是XXX.dll

改变Web Browser控件IE版本

如果值为0工作不正常或你想控制IE渲染模式的具体版本,可见下表

11001 (0x2EDF)
Internet Explorer 11. Webpages are displayed in IE11 Standards mode, regardless of the !DOCTYPE directive.

11000 (0x2AF8)
Internet Explorer 11. Webpages containing standards-based !DOCTYPE directives are displayed in IE9 mode.

10001 (0x2AF7)
Internet Explorer 10. Webpages are displayed in IE10 Standards mode, regardless of the !DOCTYPE directive.

10000 (0x2710)
Internet Explorer 10. Webpages containing standards-based !DOCTYPE directives are displayed in IE9 mode.

9999 (0x270F)
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.

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.

7000 (0x1B58)
Webpages containing standards-based !DOCTYPE directives are displayed in IE7 Standards mode.

举例11001和11000的区别是,11001始终工作在IE11模式,而11000对含!DOCTYPE标签的优先使用IE9模式,若无则工作在IE11模式.

根据需求选择你合适的版本,并不是越新越好,有时向后兼容是你需要考虑的~~

参考链接:

  http://blogs.msdn.com/b/patricka/archive/2015/01/12/controlling-webbrowser-control-compatibility.aspx

  https://weblog.west-wind.com/posts/2011/May/21/Web-Browser-Control-Specifying-the-IE-Version#FeatureDelegationviaRegistryHacks

  https://msdn.microsoft.com/en-us/library/ee330730%28VS.85%29.aspx#browser_emulation