如何在IE9中禁用兼容模式按钮?

Cyr*_*rax 10 cross-browser ie8-compatibility-mode internet-explorer-9 x-ua-compatible

我无法在IE9中禁用IE兼容模式按钮.

我的头和doctype看起来像这样:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--[if lte IE 8]> 
  <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-en" xml:lang="en-en" class="ie8">
 <![endif]-->
<!--[if IE 9]> 
  <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-en" xml:lang="en-en" class="ie9">
<![endif]-->
<!--[if (gt IE 9)|!(IE)]><!-->
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-en" xml:lang="en-en">
<!--<![endif]-->
  <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <!-- Always force latest IE rendering engine (even in intranet) & Chrome Frame -->
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta name="description" content="meta content here" />
  </head>
  <body>
    <!-- page content here //-->
  </body>
</html>
Run Code Online (Sandbox Code Playgroud)

如何在IE9中禁用兼容模式按钮?

我以为我做了我的研究.我应用了各种后备解决方案来显示从7到9及以上的每个IE中的所有内容.

客户端抱怨兼容模式,当激活时,它会弄乱布局.有没有办法禁用该按钮?

Sim*_*mon 18

<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
Run Code Online (Sandbox Code Playgroud)

截至2014年1月,Google已停止使用Chrome框架,因此不需要Chrome = 1部分

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

"边缘"强制IE中的标准模式(或最新渲染引擎),"chrome"用于Chrome Frame.

更多信息在这里:

  • 我终于得到了这个工作(虽然我没有包括`chrome`位),当我把这个标签移到*第一件事之后*在`<head>之后 (4认同)

Ben*_*Ben 5

我在页面顶部使用条件注释来嵌入ie基于版本的类.(例如:)

<!--[if IE 7 ]><html class="ie ie7" lang="en"> <![endif]-->
Run Code Online (Sandbox Code Playgroud)

因此,即使我正在设置X-UA-Compatible元标记,仍然会在IE中显示Compatability Mode按钮.

为了解决这个问题,我不得不将条件注释移到页面底部并使用JS来应用这些ie类.查看我的网站时,IE中不再显示兼容性按钮.

<html lang="en">
  <head>
    <meta http-equiv="X-UA-Compatible" content="IE=8; IE=9; IE=10; IE=EDGE; chrome=1">
  <head>
  <body>
     <!-- ..Other content... -->
  <script type="text/javascript">
   window.flagAsIE = function(version) {
     var cls = document.body.parentElement.getAttribute('class');
     document.body.parentElement.setAttribute('class', "ie ie" + version + " " + cls);
   };
  </script>

  <!--[if lt IE 7 ]><script type='text/javascript'>flagAsIE('6');</script><![endif]-->
  <!--[if IE 7 ]><script type='text/javascript'>flagAsIE('7');</script><![endif]-->
 </body>
</html>
Run Code Online (Sandbox Code Playgroud)


Dan*_*man 4

答案如下:

http://blogs.msdn.com/b/jonbox/archive/2011/03/27/removing-the-ie9-compatibility-button-and-html1115-warning.aspx

更改元标记的顺序。

  • 我正在使用 Paul Irish 提出的解决方案作为处理 x 浏览器兼容性的方法。仅解析针对特定浏览器的标签。控制台中没有弹出消息。 (2认同)