更新时间:2022-12-18 09:42:28
目前似乎不能使用 javascript:
和 data:
网址(直接在地址栏中)允许根据此评论:
It seems using javascript:
and data:
URLs (directly in the address bar) are currently not allowed as per this comment:
仅供参考,我可能会将这个错误分成多个短期和长期修复.
FYI, I'm probably going to split this bug into multiple, short and longer term fixes.
短期:禁止将 javascript: URL 粘贴到 URL 栏中
长期:另外要求书签在书签管理器在它可以运行 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
javascript: 实际上并没有被忽略——它们是运行的,但是在一个空"的上下文中,没有任何你期望的常用 DOM 方法,所以最常见的用法(例如 javascript:alert(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?
你不能,你必须等到他们决定一个合适的解决方案.正如评论所说,书签可以工作,但必须明确允许.如果您只想测试代码,请使用 Firebug 或新的 Scratchpad 功能.
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.