How to run JavaScript in Firefox URL bar?
Solution 1:
Firefox 89 and later
-
Select Settings menu (3 horizontal lines ≡ icon in the upper right corner) More Tools -> Web Developer Tools -> Console tab.
-
Type JavaScript code after the web console prompt
»
and press Enter.
The web console prompt will be located in the bottom left corner of the console pane if the console already has output in it.
Firefox 72 and later
Scratchpad is deprecated as of Firefox 70 (bug 1565380), and has been removed in Firefox 72 and later.
-
Select Settings menu (3 horizontal lines ≡ icon in the upper right corner) -> Web Developer -> Web Console.
-
Type JavaScript code after the web console prompt
»
and press Enter.
Firefox 57-71
-
Select Settings menu (3 horizontal lines ≡ icon in the upper right corner) -> Web Developer -> Scratchpad.
-
Click the Run button on the Scratchpad toolbar to run your JavaScript code.
Firefox 56 and earlier
-
Open a new tab in Firefox and in the URL bar, and enter
about:blank
to display a blank tab so that you can see what you are doing. -
From the Firefox menu select Tools -> Web Developer -> Web Console.
-
A new Web Console window will open. From the Web Console window click the JS button on the toolbar.
-
From the Web Console window click on the Scratchpad icon in the toolbar. The Scratchpad icon looks like a notepad.
-
A new Scratchpad window will open. Copy your javascript code:
javascript:alert('Hello, World')
in the Scratchpad window. -
Click the Run button on the Scratchpad toolbar to run your JavaScript code.
Solution 2:
For firefox android version, you can try this bookmarklet:
javascript:var a=prompt();var f=Function(a);f();
It will open a prompt box. Type your command in it (without "javascript:") and it will run.