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


当前回答

我相信这能达到目的:

<meta http-equiv="X-UA-Compatible" content="IE=edge" />

其他回答

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

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

基于我最近的一些经验,关于这个话题还有一些注释。我工作的大学为所有的Intranet站点提供IE 8兼容模式的笔记本电脑。我试着添加元标签,以禁用此模式的页面提供了我的网站,但IE始终忽略这个标签。正如Lance在他的帖子中提到的,添加一个响应头修复了这个问题。这是我如何设置基于HTML5样板方法的头:

<IfModule mod_headers.c>
  Header set X-UA-Compatible "IE=edge,chrome=1"
  # mod_headers can't match by content-type, but we don't want to send this header on *everything*...
  <FilesMatch "\.(appcache|crx|css|eot|gif|htc|ico|jpe?g|js|m4a|m4v|manifest|mp4|oex|oga|ogg|ogv|otf|pdf|png|safariextz|svg|svgz|ttf|vcf|webm|webp|woff|xml|xpi)$">
    Header unset X-UA-Compatible
  </FilesMatch>
</IfModule>

为了让这个头实际被发送,你必须确保在Apache中开启了mod_headers。如果你想确保你打开了这个mod,把它放在一个可以运行php的页面中:

<pre>
<?php
    print_r(apache_get_modules());
?>
</pre>

我相信这能达到目的:

<meta http-equiv="X-UA-Compatible" content="IE=edge" />

有“边缘”模式。

<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。

经过许多小时的故障排除这个东西…以下是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"