【问题标题】:HTML Conditional Comment exhibits strange behavior in IE9HTML 条件注释在 IE9 中表现出奇怪的行为
【发布时间】:2014-05-03 13:37:01
【问题描述】:

请看这个html页面:

<!DOCTYPE html>
<!--[if lt IE 7]><html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]><html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]><html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--><html class="no-js"><!--<![endif]-->
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Test</title>
    <meta name="description" content="">

    <!--[if IE 7]>
        <script type="text/javascript">alert("IE7")</script>
    <![endif]-->

    <!--[if IE 8]>
        <script type="text/javascript">alert("IE8")</script>
    <![endif]-->

    <!--[if IE 9]>
        <script type="text/javascript">alert("IE9")</script>
    <![endif]-->

</head>
<body data-pagename="home">

</body>
</html>

我不明白为什么如果我在 IE8 和 IE7 中查看它都可以正常工作,而如果我在 IE9 中查看页面,警报就像我在 IE7 中一样。
如果我之前更改了第一行带有

的头部标签
<!DOCTYPE html>
<html class="no-js">
<head>

一切正常。

好像文档类型和头部之间的某些东西改变了渲染行为。 问题是: 是我的错吗,可能是因为我以非法方式使用了某些东西,还是 IE9 的错误?

【问题讨论】:

  • 如果您完全删除前两个条件警报但将所有&lt;html&gt; 标记保留在那里怎么办?
  • 无法在 IE9 上重现。您确定您没有意外更改浏览器模式吗?检查 F12。
  • @JoeriHendrickx 我没有更改浏览器模式。我只在关闭/打开浏览器后加载页面。
  • @BoltClock 没有警报。如果我在 IE7 警报之前移动 IE8 警报,我已经 IE7。

标签: html internet-explorer internet-explorer-9 conditional-comments


【解决方案1】:

我不明白为什么如果我在 IE8 和 IE7 中查看都可以正常工作,而如果我在 IE9 中查看页面,则警报就像我在 IE7 中一样。

这很复杂:

  • 是否设置了“在兼容性视图中显示所有站点”?
    • 是否启用了“用户兼容性视图列表”?
      • 找到匹配项了吗?
    • 是否启用了“MS 兼容性视图列表”?
      • 找到匹配项了吗?
    • 是否设置了“在兼容性视图中显示 Intranet 站点”?
      • 网页是否在“内网区”?

参考文献

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-07-05
    • 2012-07-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多