如何将 FEATURE_BROWSER_EMULATION 设置为 IE8 模式?
我们在 Java 应用程序中使用嵌入式 SWT 浏览器。 SWT 浏览器包装了 IE8 WebBrowser Control 对象。我遇到了一个众所周知的问题,默认情况下,WebBrowser 控件使用 IE7 模式而不是 IE8 模式。 (请参阅 http://blogs .msdn.com/b/ie/archive/2009/03/10/more-ie8-extensibility-improvements.aspx)
根据这篇文章和其他文章,我尝试为我的应用程序设置 FEATURE_BROWSER_EMULATION 注册表值,以便浏览器默认为 IE8 模式,但我的成功程度参差不齐。使用值 8000 将其设置为 IE8 标准模式不起作用,但使用值 8888 将其设置为“强制”IE8 标准模式则有效。
我通过在 SWT 浏览器中加载页面然后执行 javascript 来测试这一点。
browser.execute("alert(document.documentMode);");
如果键值不存在或为 8000,结果为 7。如果键值为 8888,结果为 8。我测试的 URL 是http://stackoverflow.com,其中包括以下内容
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
有人知道我做错了什么吗?
We are using an embedded SWT Browser in a Java application. The SWT Browser wraps an IE8 WebBrowser Control object. I am running into the well-known issue that by default, the WebBrowser Control uses IE7 mode instead of IE8 mode. (See http://blogs.msdn.com/b/ie/archive/2009/03/10/more-ie8-extensibility-improvements.aspx)
Per this and other articles, I am trying to set the FEATURE_BROWSER_EMULATION registry value for my application so that the Browser defaults to IE8 mode, but I am having mixed success. Setting it to IE8 Standards Mode using the value 8000 does not work, butsetting it to "Forced" IE8 Standards Mode using value 8888 does.
I am testing this by loading the page in the SWT Browser and then executing the javascript
browser.execute("alert(document.documentMode);");
The result is 7 if the key value does not exist or is 8000. The result is 8 if the key value is 8888. The URL I am testing against is http://stackoverflow.com, which includes the following
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
Does anyone know what I am doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
首先检查此解决方案:
关于 IE9 WebBrowser 控件
如果它不能满足您的需求,这里是注册表解决方案
要在 IE11 标准模式下运行 WebBrowser 控件,请在注册表中使用以下新值:
要在 IE10 标准模式下运行 WebBrowser 控件,请使用以下新值进入注册表:
要在 IE9 标准模式下运行 WebBrowser 控件,请在注册表中使用以下新值:
要在 IE8 标准模式下运行 WebBrowser 控件,请使用以下命令将新值添加到注册表中:
要在 IE7 标准模式下运行,请使用以下注册表值:
Check this Solution First :
Regarding IE9 WebBrowser control
if it does not meet your need, here is the registry solution
To run a WebBrowser control in IE11 Standards Mode, use the following new value into the registry:
To run a WebBrowser control in IE10 Standards Mode, use the following new value into the registry:
To run a WebBrowser control in IE9 Standards Mode, use the following new value into the registry:
To run a WebBrowser control in IE8 Standards Mode, use the following new value into the registry:
To run in IE7 Standards Mode, use the following registry value:
检查独立 IE 中的兼容性视图设置(工具 > 兼容性视图设置)。您的页面是否列在“要在兼容性视图列表中显示的网站”中,或者是否选中了“在兼容性视图中显示所有网站”框?将 reg 值设置为 8000 后,Web 浏览器控件仍遵循兼容性视图设置。
Check the compatibility view settings in standalone IE (Tools > compatibility view settings). Is your page listed in the 'sites to display in compability view list' or is the 'show all sites in compatiblity view' box checked? With that reg value set to 8000, webbrowser control still honors compatibility view settings.