在winforms应用程序中托管的MSIEs WebBrowser控件以兼容模式运行

Kri*_*erA 9 internet-explorer webbrowser-control internet-explorer-8 winforms ie8-compatibility-mode

我以winforms形式主持MSIE.不幸的是,它坚持在兼容模式下运行,无论我是否在独立IE中给它一个在IE8模式下运行的页面.这样做的结果是,在独立的MSIE中正确呈现的某些内容在托管控件中完全错位并混乱.

除了文档类型等,还有一些神奇的方法告诉webbrowser我希望它以与在独立的MSIE中加载它相同的方式呈现页面吗?

I don't want to use the registry key override ( http://blogs.msdn.com/b/ie/archive/2009/03/10/more-ie8-extensibility-improvements.aspx ) due to my form being part of an add-in for another app. I don't want to change the IE behavior for the main app and I don't want to change it for other add-ins running under that app. I only want this to work within the browser hosted in my form, not app-wide and not process-wide.

Gar*_*ett 10

我没有对此进行测试,但是如何使用META标记以及HTTP-EQUIV属性将X-UA-COMPATIBLE值设置为IE=8,指示Web浏览器以IE 8标准模式显示页面.一个例子是:

<meta http-equiv="X-UA-Compatible" content="IE=8" />
Run Code Online (Sandbox Code Playgroud)

从以下文章中的这一行看来,这应该可行.

默认情况下,托管WebBrowser控件的应用程序在IE7模式下打开基于标准的页面,除非该页面包含适当的X-UA兼容标头.您可以通过将应用程序可执行文件的名称添加到FEATURE_BROWSER_EMULATION功能控制键并相应地设置值来更改此设置.

  • @Ian Boyd - 确保X-UA-Compatible thingie是<head>标签内的_first_标签......如果没有,IE会忽略它. (5认同)