/ * @ cc_on和IE6检测 [英] /*@cc_on and IE6 detection

本文介绍了/ * @ cc_on和IE6检测的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在研究IE的JavaScript条件评论时,我偶然发现了@cc_on。这似乎有效。但是,关于条件注释的维基百科条目提供了以下代码,用于更强大的IE检测,特别是IE6 :

When researching JavaScript conditional comments for IE, I stumbled upon @cc_on. This seems to work. However, the wikipedia entry on conditional comments provides the following code for more robust IE detections, specifically IE6:

/*@cc_on
    @if (@_jscript_version > 5.7)
    document.write("You are using IE8+");

    @elif (@_jscript_version == 5.7 && window.XMLHttpRequest)
    document.write("You are using IE7");

    @elif (@_jscript_version == 5.6 || (@_jscript_version == 5.7 && !window.XMLHttpRequest))
    document.write("You are using IE6");

    @elif (@_jscript_version == 5.5)
    document.write("You are using IE5.5");

    @else
    document.write("You are using IE5 or older");

@end

@*/

问题是,我在上获得了预期的常量javascript错误!window.XMLHttpRequest

显然维基百科需要一些帮助,我需要让它工作。任何人都可以帮助我吗?

Clearly Wikipedia needs some help, and I need to get this working. Can anyone help me out?

推荐答案

绝对没有JS专家,但是有些搜索发现这是用于使用jscript_version ==从IE7中隔离IE6 5.7:

Definitely no JS expert, but some searches found this for isolating IE6 from IE7 using jscript_version == 5.7:

/*@cc_on
if (@_jscript_version==5.6 ||
   (@_jscript_version==5.7 &&
      navigator.userAgent.toLowerCase().indexOf("msie 6.") != -1)) {
  //ie6 code
}
@*/

也许它会指向正确的方向。

Maybe it'll point you in the right direction.

资料来源:
http://sharovatov.wordpress.com/2009/06/03/efficient-ie-version-targeting/

这篇关于/ * @ cc_on和IE6检测的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆