Multiple @ JS IE中的注释bug [英] Multiple @ JS Comment bug in IE

查看:154
本文介绍了Multiple @ JS IE中的注释bug的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在IE 7,6.5(可能还有其他?)中遇到了错误/未公开的功能。这不会影响Opera(10.5x)Firefox(3.5.x)或可能的任何其他浏览器(这是我到目前为止测试的所有)。

I've come across a bug/undocumented feature in IE 7, 6.5 (perhaps others?). This doesn't effect Opera (10.5x) Firefox (3.5.x) or likely any other browser (this is all I've tested so far). It doesn't seem to be a documented ability of Javascript.

通过添加由双斜杠表示的注释,并在符号后紧跟双精灵( // @@ ),整个 .js 文件将无用。我检查了几个变体,这是我发现(其中fail = JS没有加载,pass = JS加载):

By including a comment denoted by double slashes, and directly followed by double at signs (//@@), the whole .js file is rendered useless. I've checked several variations and here's what I've found (where fail=JS isn't loaded, pass=JS is loaded):


  1. fail: // @@

  2. fail: // @ @

  3. 失败: // @@@ - 任何数量的@似乎没有影响。
  4. $
  5. 失败: // @@ text - 以下任何内容似乎不起作用
  6. code> // @ hello @ - @之间的任何内容似乎不起作用
  7. pass: @

  8. pass: // @ @ - 空格前@似乎阻止

  9. pass: // hello @@ - 任何内容之前@似乎阻止

  10. / * @@ * / - 似乎适用于 // 注释风格
  1. fail: //@@
  2. fail: //@ @
  3. fail: //@@@ - any number of @ doesn't seem to make a difference
  4. fail: //@@ text - any content following doesn't seem to help
  5. fail: //@hello@ - any content between @ doesn't seem to help
  6. pass: // @@
  7. pass: // @ @ - space before first @ seems to prevent
  8. pass: //hello @@ - any content before first @ seems to prevent
  9. pass: /*@@*/ - only seems to apply to // comment style



IE 7 - 只是忽略该文件,当试图引用该文件的内容时,您会得到一个错误,< function / object>未定义。 IE6.5具有报告无效字符的正确性,这显着提高了您找到问题的能力!

IE 7 - just ignores the file, when trying to reference the content of that file you get an error along the lines of "<function/object> is undefined". IE6.5 has the decency to report "Invalid character" which significantly improves your ability to find the problem!

因此问题:有人知道为什么会发生这种情况吗?

您可以使用它(插入一个空格,使用其他注释样式等),但它

And so the question: Does anyone know why this is happening and what's going on?
You can work with it (insert a space, use the other comment style etc) but it's worth noting the problem's there, since can be time-consuming to debug.

UPDATE:
如何重现:

UPDATE: How to reproduce:

来源: flaw.ie.html

Source: flaw.ie.html

<html lang="en">
  <head>
    <title>Test</title>
    <script src="turnon.cc.js"></script>
    <script src="flaw.ie.js"></script>
  </head>
  <body>
    World
  </body>
</html>

资料来源: flaw.ie.js

Source: flaw.ie.js

//@@
alert('hello');

资料来源: turnon.cc.js

Source: turnon.cc.js

/*@cc_on
 @*/

结果:

IE:page:World

FF / Opera:Alert:Hello!页面:世界

Result:
IE: page:World
FF/Opera: Alert:Hello! page:World

潜在的结论:一旦在IE中启用条件编译,请注意类似语法的注释。

Potential conclusion: Once conditional compilation is turned on in IE, be careful with comments that vaguely resemble the syntax.

推荐答案

最有可能与条件注释有关:

Most likely related to conditional comments:

http://www.javascriptkit.com/javatutors/conditionalcompile.shtml

这篇关于Multiple @ JS IE中的注释bug的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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