javascript:/ * @ @ * /是什么意思? [英] javascript: what does /*@ @*/ mean?
问题描述
有人可以解释html5shim脚本的开头和结尾如何工作吗?
Can someone explain how the beginning and end of the html5shim script works?
脚本以 / * @ $ c $开头c>并以
@ * /
结尾,如下所示:
the script starts with /*@
and ends with @*/
like this:
/*@cc_on(function(a,b){function ........ (this,document);@*/
/ * @ @ * /
在做什么?
我希望/ * * /序列注释掉它们之间的所有行,但是由于脚本执行了,所以这里不是这种情况吗?我很困惑。
I would expect the /* */ sequence to comment out all lines in between them, but since the script executes, that cant be the case here? I'm confused.
位于:
推荐答案
IE的JScript支持条件编译,这是一种在注释中隐藏特定于浏览器的特殊信息的技巧,即 /*@...@*/
是一个不寻常的字符序列,因此可以安全地重新使用t来介绍这项新的语法级功能。
IE's JScript supports ‘conditional compilation’, a trick of hiding special browser-specific information in comments. The idea is that /*@...@*/
is such an unusual sequence of characters that it is safe to repurpose it to introduce this new syntax-level feature.
html5shiv使用它来创建一段代码,甚至不会尝试在大多数浏览器上运行(就像您做到了,会将整个内容解释为一个值得称赞的内容),但是对IE而言具有特殊含义。
html5shiv uses it to create a piece of code that won't even try to run on most browsers (which, like you did, will interpret the whole thing as a commend), but which has special meaning to IE.
此处为MS文档。没有其他JS引擎支持此功能。通常,您可能更喜欢使用更明确的行为嗅探代码,但是,如果您确实需要检测不会使自身暴露于嗅探的IE功能,则它会很方便。
MS doc here. No other JS engine supports this. Typically you might favour more explicit behaviour-sniffing code instead, but if you really need to detect an IE feature that doesn't expose itself to sniffing otherwise, it can be handy.
这篇关于javascript:/ * @ @ * /是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!