簡體   English   中英

如何停止僅適用於IE 8的腳本

[英]how do I stop a script only for IE 8

我必須停止在IE8和7上提到的以下javascript文件。當我刪除“ response-nav.js”時,響應導航在IE更高版本上不起作用。 因此,請任何人建議停止在IE8和7上的工作。

<script type="text/javascript" src="js/responsive-nav.js"></script>

您可以使用下層顯示條件注釋:

<![if IE gt 8]><script ...></script><![endif]>

但是請注意,使用此類注釋會導致您的頁面由於“未知標簽”而無法通過驗證。

HTML條件注釋

<!--[if !((IE 7)||(IE 8))]--> <script>...</script> <!--[endif]-->
<!--[if !IE 8]><!-->
<script type="text/javascript" src="js/responsive-nav.js"></script>
<!--<![endif]-->

這稱為條件語句。 “!” 在“ IE”之前表示“不是”,因此該語句在說:如果此瀏覽器不是IE,請運行此腳本。

您還可以像這樣定位特定版本的IE:

<!--[if IE 6]>
Special instructions for IE 6 here
<![endif]-->

<!--[if IE 8]>
Special instructions for IE 6 here
<![endif]-->

<!--[if IE 8]>
Special instructions for IE 6 here
<![endif]-->

暫無
暫無

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

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