为什么这些条件评论告诉我IE8是IE7?

时间:2011-03-24 09:29:48

标签: html internet-explorer conditional-comments

为什么在Internet Explorer 8上使用此HTML页面:

<p>
<!--[if IE]> According to the conditional comment this is Internet Explorer<br /><!    [endif]-->
<!--[if IE 5]> According to the conditional comment this is Internet Explorer 5<br /> <![endif]-->
<!--[if IE 5.0]> According to the conditional comment this is Internet Explorer 5.0<br /> <![endif]-->
<!--[if IE 5.5]> According to the conditional comment this is Internet Explorer 5.5<br /> <![endif]-->
<!--[if IE 6]> According to the conditional comment this is Internet Explorer 6<br /> <![endif]-->
<!--[if IE 7]> According to the conditional comment this is Internet Explorer 7<br /> <![endif]-->
<!--[if gte IE 5]> According to the conditional comment this is Internet Explorer 5 and up<br /><![endif]-->
<!--[if lt IE 6]> According to the conditional comment this is Internet Explorer lower than 6<br /> <![endif]-->
<!--[if lte IE 5.5]> According to the conditional comment this is Internet Explorer lower or equal to 5.5<br /> <![endif]--> 
<!--[if gt IE 6]> According to the conditional comment this is Internet Explorer greater than 6<br /> <![endif]--> 
</p>

我得到了这个结果?

According to the conditional comment this is Internet Explorer
According to the conditional comment this is Internet Explorer 7
According to the conditional comment this is Internet Explorer 5 and up
According to the conditional comment this is Internet Explorer greater than 6

我不应该得到IE8吗?

感谢。

2 个答案:

答案 0 :(得分:5)

唯一不正确的评论

  

根据条件评论   这是Internet Explorer 7

浏览器是否处于兼容模式,因为它将呈现为IE7

答案 1 :(得分:2)

对于本地文档,IE8倾向于自动使用IE7兼容模式。在这种情况下,IE8就好像它是IE7(有一些怪癖)。

您要么在本地测试,要么您的浏览器当前设置为IE7兼容模式。