我正在为一个在所有内部网站点上强制兼容模式的客户端工作。我想知道是否有一个标签,我可以把我的HTML强制兼容性模式关闭。


当前回答

元标签解决方案并不适合我们,但在响应头中设置它却可以:

header('X-UA-Compatible: IE=edge,chrome=1');

其他回答

在回答相关问题时,建议在Web中设置“边缘”模式。配置文件。这将使它适用于从应用程序返回的所有HTML,而不需要将它插入到单个页面:

<configuration>
    <system.webServer>
        <httpProtocol>
            <customHeaders>
                <add name="X-UA-Compatible" value="IE=edge" />
            </customHeaders>
        </httpProtocol>
    </system.webServer>
</configuration>

同样的步骤也可以通过使用IIS管理器为IIS服务器、整个网站或特定应用程序修改“HTTP响应头”来完成。

如果你想要每个单独的网页加载所选择的内容,并使用asp.net。只需将其应用为视图>共享>Layout.cshtml中的标题标签下的第一个标签

只是一个小提示

IE8对外网默认为“标准模式”,内网默认为“怪异模式”。 如果将doctype设置为xhtml transitional,则忽略HTML元标记。 解决方案是在代码中添加HTTP报头。 这对我们很管用。 现在我们的内部网正在强制IE8以标准模式呈现应用程序。

添加到基页类的PageInit (ASP.net c#):

Response.AddHeader("X-UA-Compatible", "IE=EmulateIE8");

参考: http://ilia.ws/archives/196-IE8-X-UA-Compatible-Rant.html

经过许多小时的故障排除这个东西…以下是x - ua兼容文档中的一些快速重点内容:http://msdn.microsoft.com/en-us/library/cc288325(VS.85).aspx#ctl00_contentContainer_ctl16

使用<meta http-equiv="X-UA-Compatible" content=" _______ " />

The Standard User Agent modes (the non-emulate ones) ignore <!DOCTYPE> directives in your page and render based on the standards supported by that version of IE (e.g., IE=8 will better obey table border spacing and some pseudo selectors than IE=7). Whereas, the Emulate modes tell IE to follow any <!DOCTYPE> directives in your page, rendering standards mode based the version you choose and quirks mode based on IE=5 Possible values for the content attribute are: content="IE=5" content="IE=7" content="IE=EmulateIE7" content="IE=8" content="IE=EmulateIE8" content="IE=9" content="IE=EmulateIE9" content="IE=edge"

插入 作为标签下的第一件物品。

这将迫使IE在IE的物理版本中呈现页面,并忽略浏览器的“模式设置”。这可以在开发人员工具中设置,尝试将其更改为旧版本的IE进行测试,这应该被忽略,页面应该看起来完全相同。