C# Web 浏览器组件是 IE7 不是 IE8?如何改变这个?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1786905/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Web Browser component is IE7 not IE8? How to change this?
提问by Chris
So I have an C# Form application that utilizes the web browser component. Apparently Response.Write(Request.Browser.Version.ToString()); returns "7.0" when I visit my test page from the web browser component.
所以我有一个使用 Web 浏览器组件的 C# 表单应用程序。显然 Response.Write(Request.Browser.Version.ToString()); 当我从 Web 浏览器组件访问我的测试页面时返回“7.0”。
How can I make this web browser component use IE8?
我怎样才能让这个 Web 浏览器组件使用 IE8?
采纳答案by Plip
It appears you need to fiddle with the registry as per this article: -
看来您需要按照本文修改注册表:-
http://blogs.msdn.com/ie/archive/2009/03/10/more-ie8-extensibility-improvements.aspx
http://blogs.msdn.com/ie/archive/2009/03/10/more-ie8-extensibility-improvements.aspx
To run a WebBrowser control in IE8 Standards Mode, use the following new value into the registry:
要在 IE8 标准模式下运行 WebBrowser 控件,请在注册表中使用以下新值:
[(HKEY_CURRENT_USER or HKEY_LOCAL_MACHINE)\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION]
"MyApplication.exe" = dword 8000 (Hex: 0x1F40)
To run in IE7 Standards Mode, use the following registry value:
要在 IE7 标准模式下运行,请使用以下注册表值:
[(HKEY_CURRENT_USER or HKEY_LOCAL_MACHINE)\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION]
"MyApplication.exe" = dword 7000 (Hex: 0x1B58)
For IE8 RTM, we've added a new “forced” IE8 Standards Mode value. When an application opts into this mode, the Web Browser control will use the IE8 User-Agent string and Browser Emulation mode strictly. It will also ignore fallback features such as the built-in Compatibility View list and the user-generated Compatibility View list when loading pages. To run in “forced” IE8 Standards Mode, use the following registry value:
对于 IE8 RTM,我们添加了一个新的“强制”IE8 标准模式值。当应用程序选择此模式时,Web 浏览器控件将严格使用 IE8 用户代理字符串和浏览器仿真模式。它还会在加载页面时忽略回退功能,例如内置的兼容性视图列表和用户生成的兼容性视图列表。要在“强制”IE8 标准模式下运行,请使用以下注册表值:
[(HKEY_CURRENT_USER or HKEY_LOCAL_MACHINE)\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION]
"MyApplication.exe" = dword 8888 (Hex: 0x22B8)
In all of these examples, “MyApplication.exe” refers to the name of your application.
在所有这些示例中,“MyApplication.exe”是指您的应用程序的名称。
回答by Pascal Ganaye
I did follow this and it was not working until I realized it was because I was debugging in visual studio.
我确实遵循了这个,直到我意识到这是因为我在 Visual Studio 中调试它才起作用。
On top of setting the registry for your application:
除了为您的应用程序设置注册表之外:
Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION",
System.AppDomain.CurrentDomain.FriendlyName, value);
You should also set it for your debugging (visual studio hosted) application:
您还应该为您的调试(visual studio 托管)应用程序设置它:
Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION",
System.AppDomain.CurrentDomain.FriendlyName.Replace(".exe",".vshost.exe"), value);
回答by Archimedix
The answer may come late and might not apply to your case, but according to Ron's answer on the question WPF .net4 webBrowser and Internet Explorer 8, you can also control the web browser if you have control over the served page:
答案可能会迟到并且可能不适用于您的情况,但根据 Ron 对问题WPF .net4 webBrowser 和 Internet Explorer 8的回答,如果您可以控制所提供的页面,您还可以控制网络浏览器:
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
While this apparently does not change the user agent, it seems that conditionals like
虽然这显然不会改变用户代理,但似乎条件像
<!--[if lt IE 8]>
and CSS border-radius
are being evaluated properly, indicating that the newest engine (IE 9 on my system) is actually being used despite the user agent reporting MSIE 7.0.
和 CSSborder-radius
正在正确评估,表明尽管用户代理报告 MSIE 7.0,但实际上正在使用最新的引擎(我系统上的 IE 9)。