在研究 IE 的 JavaScript 条件注释时,我偶然发现了@cc_on。这似乎有效。但是,关于条件注释的维基百科条目提供了以下代码,用于更强大的 IE 检测,特别是 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
@*/
问题是,我在!window.XMLHttpRequest
.
显然维基百科需要一些帮助,我需要让这个工作。谁能帮我吗?