所以我需要檢測IE 9.我知道我應該真的使用feature detection,但我不知道什麼功能導致我的問題我所知道的是,即9是導致我的問題。檢測IE9沒有功能檢測
我有一個解決我的問題的方法(對於那些有興趣的人,我問了一個關於問題here的問題,但真的,這是無關緊要的)。
現在我想實施這
黑客
修復只爲IE9,因爲這是什麼讓我頭痛。
那麼如何檢測IE 9的最佳方式?
所以我需要檢測IE 9.我知道我應該真的使用feature detection,但我不知道什麼功能導致我的問題我所知道的是,即9是導致我的問題。檢測IE9沒有功能檢測
我有一個解決我的問題的方法(對於那些有興趣的人,我問了一個關於問題here的問題,但真的,這是無關緊要的)。
現在我想實施這
黑客
修復只爲IE9,因爲這是什麼讓我頭痛。
那麼如何檢測IE 9的最佳方式?
這些IE條件語句會給你一個CSS類鑰匙關閉的:
<!--[if lt IE 7]> <html class="lt-ie10 lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
<!--[if IE 7]> <html class="lt-ie10 lt-ie9 lt-ie8" lang="en"> <![endif]-->
<!--[if IE 8]> <html class="lt-ie10 lt-ie9" lang="en"> <![endif]-->
<!--[if IE 9]> <html class="lt-ie10" lang="en"> <![endif]-->
<!--[if gt IE 9]><!--> <html lang="en"> <!--<![endif]-->
所以,如果你只關心IE9,你可以這樣做:
<!--[if IE 9]> <html class="ie9" lang="en"> <![endif]-->
或者,保持與約定:
<!--[if IE 9]> <html class="lt-ie10" lang="en"> <![endif]-->
然後,你的JS(和CSS)可鍵關機的HTML.lt-IE10選擇:
if ($('HTML.lt-ie10').length) {
//this is IE9 and older
}
else {
//this is not IE9 and older (so it could be Chrome, or Safari or IE10, etc)
}
使用jQuery(1.8或更低)
if ($.browser.msie && $.browser.version == 9) {
// Your code here
}
'瀏覽器'屬性已被棄用,並在jQuery 1.9中被刪除。 –
沒有意識到這有一個版本以及msie國旗! – Liam
@JamesAllardice,我沒有意識到,他們爲什麼要那樣做!作爲@JamesAllardice的 –
IE條件評論... – Musa
http://api.jquery.com/jQuery.browser/ – mavili
$ .browser一直以來的jQuery 1.3棄用並已在1.9中刪除 – jmoerdyk