【问题标题】:IE8 forcing document mode as IE7 standardsIE8 强制文档模式为 IE7 标准
【发布时间】:2013-02-21 02:50:04
【问题描述】:

对于我的网络应用程序,我使用 IE8 作为标准浏览器。有时浏览器会将文档模式设置为 IE-7 标准。

我已经尝试过 Servlet Headers 作为 IE=8,IE=edge 和所有其他设置,我的 DOCTYPE 也是正确的。

有谁知道为什么 IE 会强迫这种行为?

【问题讨论】:

  • 你能分享文档类型和使用的元标记
  • 正确检查您的文档类型。如果不正确。然后它将强制进入怪癖模式。
  • 你使用的是哪个服务器(iis、apache)?

标签: internet-explorer-8


【解决方案1】:

我解决了类似的问题:

<meta http-equiv="X-UA-Compatible" content="IE=8,IE=9,IE=10,chrome=1" />

考虑到IE版本应该从最低版本开始。

【讨论】:

    【解决方案2】:

    你可以强制IE使用X-UA-Compatible Meta Tag的兼容模式:

    IE 7:

    <meta http-equiv="X-UA-Compatible" value="IE=7">
    

    IE 8:

    <meta http-equiv="X-UA-Compatible" value="IE=8">
    

    IE 9:

    <meta http-equiv="X-UA-Compatible" value="IE=9">
    

    IE查看页面DOCTYPE:

    标准视图

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
      <head>
        <title>This page is NOT Rendered in Compatibility View</title>
      </head>
      <body>
        <h1>This page is NOT Compatibility View</h1>
      </body>
    </html>
    

    兼容性视图

    <html>
      <head>
        <title>This page is NOT Rendered in Compatibility View</title>
      </head>
      <body>
        <h1>This page is NOT Compatibility View</h1>
      </body>
    </html>
    

    标准视图

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
      <head>
        <title>This page is NOT Rendered in Compatibility View</title>
      </head>
      <body>
        <h1>This page is NOT Compatibility View</h1>
      </body>
    </html>
    

    兼容性视图

    <?xml version="1.0" encoding="UTF-8">
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html>
      <head>
        <title>This page is NOT Rendered in Compatibility View</title>
      </head>
      <body>
        <h1>This page is NOT Compatibility View</h1>
      </body>
    </html>
    

    注意,最后一个示例应该在 XHTML 模式下作为标准视图加载。但 Internet Explorer 将该 XML 声明解释为需要兼容性视图。

    【讨论】:

    • 这是元标记:- 这是 Doctype
    • @Magician 在头部
    • 是的,我已经添加了元标记。没有其他元标记。如果我手动更改文档模式它正在工作,但有时我会遇到同样的问题。我什至检查了所有的东西代码也经过验证,因此没有代码级错误。
    • @Magician 你在用 XHTML 吗?
    • @Magician 你看过我的例子吗?
    猜你喜欢
    • 2012-04-29
    • 1970-01-01
    • 2012-12-03
    • 2011-02-05
    • 2013-06-08
    • 2010-11-04
    • 2012-10-28
    • 2011-03-09
    相关资源
    最近更新 更多