Javascript Don';t在IE6或更低版本中加载脚本
我如何添加一个条件,以便在用户运行IE6或更低版本时不加载一些javascript。我尝试了以下操作,但Javascript Don';t在IE6或更低版本中加载脚本,javascript,html,internet-explorer,conditional-comments,Javascript,Html,Internet Explorer,Conditional Comments,我如何添加一个条件,以便在用户运行IE6或更低版本时不加载一些javascript。我尝试了以下操作,但不会加载到任何浏览器中: <!--[if gt IE 6]> <script blah blah blah... /> <![endif]--> <!--[if ! IE 6]> <script blah blah blah... /> <![endif]--> <!--[if !IE 6]> <sc
不会加载到任何浏览器中:
<!--[if gt IE 6]>
<script blah blah blah... />
<![endif]-->
<!--[if ! IE 6]>
<script blah blah blah... />
<![endif]-->
<!--[if !IE 6]>
<script blah blah blah... />
<![endif]-->
如果您能提供一些帮助,我们将不胜感激。请阅读此内容,如果有帮助的话 我以前只使用过[if IE 6],但效果很好。你试过吗?您可以先加载该脚本,然后将实际的脚本加载包装到一个条件中,类似于:
<script>
if(!isIE6) {
head.js("path/to/script1.js", "path/to/script2.js");
}
</script>
如果(!isIE6){
js(“path/to/script1.js”、“path/to/script2.js”);
}
试试这个:
<!--[if gt IE 6]><!-->
<script blah blah blah... />
<!--<![endif]-->
上面的语法(带有额外的注释分隔符)已经解释过了。使用双否定来排除在特定IE版本上运行的脚本
<!-- disabled all javascript in IE6 -->
<!--[if gt IE 6]><!-->
<script type="text/javascript">
// special not IE6 stuff
</script>
<!--<![endif]-->
//特别的不是IE6的东西
使用简单的检查仅在IE6上运行脚本
<!--[if lte IE 6]>
<script type="text/javascript">
// special IE6 stuff
</script>
<![endif]-->
只需加载IE 7及更高版本的脚本即可
<!-- [if gte IE 7]>
<script type="text/javascript">
</script>
<![endif]-->
参考。只有我想IE浏览器才会理解这一点。其他浏览器不理解条件注释。@easwee:请参阅链接文章。@easwee,
会在非IE浏览器看到注释关闭时处理它们。。