2011-03-24 24 views
3

使用的Internet Explorer 8的這個HTML頁面爲什麼:爲什麼這些有條件的評論告訴我IE8是IE7?

<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

您使用IE7兼容模式嗎? – Oded 2011-03-24 09:31:56

+0

測試頁:http://jsbin.com/arusa5(我沒有看到該行,順便) – Kobi 2011-03-24 09:34:52

回答

5

出現不正確它

按照條件註釋 這是Internet Explorer 7中

的唯一評論是在兼容模式瀏覽器,因爲這將呈現爲IE7

+2

這可能是一個好主意,還檢查DOCTYPE,或試圖驗證的頁面。我認爲微軟也有一個META標籤來觸發兼容模式。 – Kobi 2011-03-24 09:37:11

2

對於本地文檔,IE8傾向於自動使用IE7兼容模式。在這種情況下,IE8就好像它是IE7一樣(有一些怪癖)。

你在本地測試這個,或者您的瀏覽器目前在IE7兼容模式設置。

相關問題