簡體   English   中英

Internet Explorer + Windows Phone IEMobile條件注釋

[英]Internet Explorer + Windows Phone IEMobile Conditional Comments

因此,我一直在使用IE條件句的以下兩種組合:

<!--[if (IE)|(IEMobile)]>
    <script type="text/javascript">
        // Do something
    </script>
<![endif]-->

<!--[if (!IE)|(!IEMobile)]>
    <script type="text/javascript">
        // Do something else
    </script>
<!--<![endif]-->

這樣的組合在生產環境中可以工作嗎? 我嘗試使用IE 11進行測試,以模擬到任何以前的IE版本,並得到以下結果:

  • 第一個在PC的IE上工作;
  • 第二個未能將其內容公開給PC的IE;
  • 我沒有測試IEMobile,因為我沒有Windows Phone,所以我不確定其中是否可以使用這些功能。 有什么建議么?

我不確定您要做什么,但是您應該對功能檢測進行更改。 而不是使用瀏覽器檢測。 嘗試使用http://modernizr.com/ ,您可以執行以下操作:

if(Modernizr.touch){
    // Do something
} else {
    // Do something else
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM