JavaScript警告在Firefox 6不工作

问题描述:

我试着在Firefox 6运行在地址栏中输入该JavaScript code:

I tried running this JavaScript code in the address bar in Firefox 6:

javascript:alert("Hello")

我收到了

的ReferenceError:没有定义的警报

ReferenceError: alert not defined.

它曾经在Firefox 5做工精细,虽然,仍然工作在Opera,Safari和Chrome。我该如何解决这个问题?

It used to work fine in Firefox 5 though, and still works on Opera, Safari and Chrome. How do I fix this?

好像使用的javascript:数据:网址(直接在地址栏)目前不允许按照此评论

It seems using javascript: and data: URLs (directly in the address bar) are currently not allowed as per this comment:

通知你,我可能会到这个bug分割成多个,短期和长期修复。

FYI, I'm probably going to split this bug into multiple, short and longer term fixes.

短期:禁止JavaScript代码粘贴:网址到地址栏搜索
  从长期来看:另外需要在那个小书签被列入白名单
               书签管理器,才可以运行JavaScript

Short term: disallow pasting of javascript: URLs into the URL bar
Longer term: additionally require that bookmarklets be "whitelisted" in the Bookmark Manager before it can run JavaScript

这是错误这是在的latest版本。该最后的评论还指出:

And this is the "bug" that was resolved in the latest version. The last comment also states:

JavaScript的:实际上并没有忽视 - 他们正在运行,但在没有任何通常的DOM方法,你所期望的,所以最常见的用途是空的情况下(如JavaScript的:警报(1))只是扔(从而有效地忽略)。 JavaScript的:1 + 1工作正常,但

javascript: is not actually ignored - they're run, but in an "empty" context that doesn't have any of the usual DOM methods you would expect, so most common uses (e.g. javascript:alert(1)) just throw (and thus are effectively ignored). javascript:1+1 works fine, though.

现在

我该如何解决这个问题?

How do I fix this?

您不能,你不得不等待,直到他们决定一个适当的解决方案。正如评论所说,小书签将工作,但必须明确允许的。如果你只是想测试code,使用萤火虫或新的便签功能。

You can't, you have to wait until they decided for a proper solution. As the comment said, bookmarklets will work, but must be explicitly allowed. If you just want to test code, use either Firebug or the new Scratchpad feature.