强制指定IE浏览器版本

强制IE浏览器、WebBrowser控件使用指定版本显示网页

       自从升级IE11之后,就发现好些个网站显示都不是那么的正常,网站上有些功能竟然还会出现一些意想不到的BUG,有些程序就是针对IE开发的,现在IE下竟然用不起来了,让用户情何以堪?但是就为少量用户使用的系统去大动干戈的调整功能,这实在是让人头疼!在经过一番折腾之后,竟然找到一个非常巧妙的方法来解决。 强制把高版本的IE浏览器用低地版本模式显示网页。

       就是直接让IE11默认以指定的IE版本的浏览器模式来运行,并用这个指定的版本来进行解析页面,在上一篇定义文档兼容性的文章中,我们已经其实知道了浏览器模式和文档模式的 区别,并且我们通过修改X-UA-Compatible来修改了浏览器的文档模式。这个方法本来能够解决我们当下的问题,但实际上,我们不想让整个网站用 IE8或者IE7来解析,我们仅是想针对少数的几个人在核心的功能上使用IE8来处理。我们寻求一个解决方案:由于使用核心功能的人群可控,并且数量少。因此直接控制IE,让高版本的浏览器(版本>=8)按照指定的 低版本模式进行解析。方法是直接调整注册表项。

  • HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION
  • 或者
  • HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION

       在注册表的FEATURE_BROWSER_EMULATION项下添加一个DWORD(32-位)的值,名称为:iexplore.exe值为十进制的8888或者8000后,你重启IE浏览器,在打开浏览器时会发现,浏览器此时使用的是IE8模式进行浏览。

       使用这种方法解决IE浏览器控件的应用程序,其实还可以修改不同的版本,你可以打开上面两个注册表项的任意一个,说不定注册表上能看到上面已经有值,这些值都是已经指定特定浏览器版本的程序。

       在此我们IE浏览器和控件指定特定的浏览器版本来运行,但可能你会发现,页面样式显示的不理想,那么要使用IE浏览器怎么办?需要修改后面的数值,下面就列出了常用的数值对照说明表:

FEATURE_BROWSER_EMULATION设置说明
说明
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
10000(0x2710) Internet Explorer 10. 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.
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.