Friday, May 10, 2024
 Popular · Latest · Hot · Upcoming
185
rated 0 times [  189] [ 4]  / answers: 1 / hits: 17676  / 13 Years ago, sun, july 10, 2011, 12:00:00

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



javascript:alert(Hello)


I get a




ReferenceError: alert not defined.




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


More From » browser

 Answers
18

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.



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




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




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.




Now:




How do I fix this?




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.


[#91265] Friday, July 8, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
yvettel

Total Points: 517
Total Questions: 101
Total Answers: 102

Location: Vanuatu
Member since Wed, Oct 14, 2020
4 Years ago
;