Ubuntu – How to run JavaScript in Firefox URL bar

firefoxjavascript

I am using Firefox and am trying to run this code on the URL bar javascript:alert(document.cookie);.

But, when I hit go, nothing happens. In Chromium, it alerts, so what is with Firefox? Does Firefox try HTTP by default? If so, then how do I prevent this?

Best Answer

  • Firefox 72 and later

    Scratchpad is deprecated as of Firefox 70 (bug 1565380), and has been removed in Firefox 72 and later.

    1. Select Settings menu (3 horizontal lines icon in the upper right corner) -> Web Developer -> Web Console.

    2. Type JavaScript code after the web console prompt » and press Enter.

    Firefox 57-71

    1. Select Settings menu (3 horizontal lines icon in the upper right corner) -> Web Developer -> Scratchpad.

    2. Click the Run button on the Scratchpad toolbar to run your JavaScript code.


    Firefox 56 and earlier

    1. 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.

    2. From the Firefox menu select Tools -> Web Developer -> Web Console.

    3. A new Web Console window will open. From the Web Console window click the JS button on the toolbar.

    4. From the Web Console window click on the Scratchpad icon in the toolbar. The Scratchpad icon looks like a notepad.

    5. A new Scratchpad window will open. Copy your javascript code: javascript:alert('Hello, World') in the Scratchpad window.

    6. Click the Run button on the Scratchpad toolbar to run your JavaScript code.