HTML条件注释在IE9中表现出奇怪的行为
请查看此html页面:HTML条件注释在IE9中表现出奇怪的行为,html,internet-explorer,internet-explorer-9,conditional-comments,Html,Internet Explorer,Internet Explorer 9,Conditional Comments,请查看此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-i
<!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>
一切正常
就好像doctype和head之间的某些东西改变了呈现beahviour。
问题是:
这是我的错,可能是因为我非法使用了某些东西,还是IE9的错
我不明白为什么如果我在IE8和IE7中查看它都可以正常工作,而如果我在IE9中查看页面,警报就像我在IE7中一样
这很复杂:
- 是否设置了“在兼容性视图中显示所有站点”?
- 是否启用了“用户兼容性视图列表”?
- 找到匹配项了吗
- 是否启用了“MS兼容性视图列表”?
- 找到匹配项了吗
- 是否设置了“在兼容性视图中显示Intranet站点”?
- 网页是否位于“内部网区域”
- 是否启用了“用户兼容性视图列表”?
标记保留在那里会怎么样?无法在IE9上复制。您确定没有意外更改浏览器模式吗?检查F12。@JoeriHendrickx我没有更改浏览器模式。我仅在关闭/打开浏览器后加载页面。@BoltClock无警报。如果我在IE7警报之前移动IE8警报,我就有了IE7。