【发布时间】: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 的错误?
【问题讨论】:
-
如果您完全删除前两个条件警报但将所有
<html>标记保留在那里怎么办? -
无法在 IE9 上重现。您确定您没有意外更改浏览器模式吗?检查 F12。
-
@JoeriHendrickx 我没有更改浏览器模式。我只在关闭/打开浏览器后加载页面。
-
@BoltClock 没有警报。如果我在 IE7 警报之前移动 IE8 警报,我已经 IE7。
标签: html internet-explorer internet-explorer-9 conditional-comments