2011-12-14 34 views
6

我想在Windows Mobile 7.5上定位IE瀏覽器。誰能告訴我是否有沒有辦法使用條件註釋來定位Windows Mobile 7.5瀏覽器?

<!--[if lt IE <mobile browser>]> <include retina display> <[end if]--> 

條件註釋語法樣式適用於定位Windows Mobile?

編輯:由於下面的評論我能找到解決方案。 The <!--[if IEMobile]> <[end if]-->語法適用於Windows Mobile 7,但我無法使它適用於Windows Mobile 7.5。因爲我正在構建一個不需要在桌面設備上呈現出色的移動網站,所以我能夠使用通用的<!--[if gt IE 7]>評論來解決我在兩個呈現之間存在的問題。

如果任何人有一個更優雅的解決方案,因爲所需的桌面支持,這將無法正常工作,我很樂意聽到它。

+0

你能結合兩者嗎? `<! - [if IEMobile]><! - [if gt IE 7] - > ... ` – mange 2011-12-15 03:36:35

+0

在我的模擬器7.5測試中甚至不會觸發`<! - [if IEMobile ]>`。就有條件的評論而言,它就像IE9一樣。 – donut 2012-01-23 21:39:26

回答

1

可能是這對你的工作

<!--[if IEMobile]> 
... 
<![endif]--> 
0
<pre> 
<code> 
is this help for you by checking device width? 
<!-- [if (min-device-width: 481px)]> 

<![endif]—> 
</code> 
</pre> 
2

萬一有人遇到這個問題。一些值得了解的點:

IE Mobile 7.5報告字體的誤報。因此,你用Modernizr爲這個特性付出了代價。

要混淆事項,它也會忽略IE Mobile的條件註釋,如上所示。它實際上爲IE9提供有條件的評論。我是能夠解決的唯一途徑是增加一個有條件的評論是這樣的:

<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]--> 
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8" lang="en"> <![endif]--> 
<!--[if IE 8]> <html class="no-js lt-ie9" lang="en"> <![endif]--> 
<!--[if IE 9]> <html class="no-js ie9 ieMobile75" lang="en"> <![endif]--> 
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]--> 

然後前綴相關的風格與.ieMobile75類。如果你想避免這些風格擊中桌面IE瀏覽器,我會建議在媒體查詢中結合它們。

相關問題