我有一个很好看的花哨脚本,但不是必不可少的惊喜,与IE不搭配。 我如何'为IE评论'?
我知道我可以将以下内容用于IE的 include 语句,但我如何排除呢?
<!--[if IE 6]>
Special instructions for IE 6 here
<![endif]-->
答案 0 :(得分:4)
答案 1 :(得分:3)
对于所有IE版本:
<!--[if !IE]>
conditional stuff
<![endif]-->
答案 2 :(得分:0)
不幸的是,没有排除脚本的机制(即除非脚本仅针对IE,否则请参阅ramblex / karim79的答案)。
但是......你可以修改你的脚本以检查全局(是的,我知道叹气)变量 - 当设置时 - 使脚本停止。沿线的东西:
// wrap your nice script in an anonymous function
(function(document, undefined) {
if ( window.ie6 === true ) return;
.....
})(document);
现在继续使用条件标记包含全局变量,如下所示:
<!--[if lte IE 6]>
window.ie6 = true;
<![endif]-->
Et瞧。