我正在为一个在所有内部网站点上强制兼容模式的客户端工作。我想知道是否有一个标签,我可以把我的HTML强制兼容性模式关闭。
当前回答
插入 作为标签下的第一件物品。
这将迫使IE在IE的物理版本中呈现页面,并忽略浏览器的“模式设置”。这可以在开发人员工具中设置,尝试将其更改为旧版本的IE进行测试,这应该被忽略,页面应该看起来完全相同。
其他回答
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"
元标签解决方案并不适合我们,但在响应头中设置它却可以:
header('X-UA-Compatible: IE=edge,chrome=1');
有“边缘”模式。
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>My Web Page</title>
</head>
<body>
<p>Content goes here.</p>
</body>
</html>
从链接的MSDN页面:
Edge模式告诉Windows Internet Explorer以最高可用模式显示内容,这实际上打破了“锁定”模式。在IE8中,这相当于IE8模式。如果(假设)未来的ie版本支持更高的兼容性模式,设置为Edge模式的页面将以该版本支持的最高模式显示;然而,当使用IE8浏览时,这些页面仍然会以IE8模式显示。
但是,在生产使用中不鼓励使用“edge”模式:
建议Web开发人员将Edge模式的使用限制在测试页面和其他非生产用途上,因为在Windows Internet Explorer的未来版本中呈现页面内容可能会出现意想不到的结果。
说实话,我不完全明白为什么。但根据这一点,目前最好的方法是使用IE=8。
我相信这能达到目的:
<meta http-equiv="X-UA-Compatible" content="IE=edge" />