How to Run JavaScript in Chrome and Firefox Browsers?

Image about How to Run JavaScript in Chrome and Firefox Browsers?

Nowadays, modern browsers don’t allow the running of JavaScript code from the URL/address bar due to security reasons, then how do you run avaScript in Firefox or Chrome browser?. For instance, if you want to know when a web page was updated last time, for that, you need to run the javascript: alert(document.lastModified) command.

Now, when you copy and paste it into the address bar and press enter, then the browser displays the search results for that with the default search engine, and the command simply won’t execute.

Stop Annoying JavaScript Popups in Chrome with this Extension

Run JavaScript in Chrome and Firefox console

Chrome:

1. Open the web page or site, on which, you want to run the JavaScript command.

2. Now from the Chrome menu > More tools > Developer tools (Ctrl+Shift+I)

3. Click on Console or use the Ctrl+Shift+ J shortcut instead or you can bring the console to the front by right-clicking on the page and selecting ‘Inspect element’ , … so many ways to open the JavaScript Console in Chrome.

3. Once JavaScript Console opens, clear the console log (Ctrl+L),

4. Type the script you want to execute and press enter,

5. A pop-up dialog appears on top and shows the result (check the screenshot below), click on ‘OK’ to dismiss it.

 

Disable JavaScript in Chrome, Firefox, Opera, and Internet Explorer Browsers

Firefox

1. Open Firefox menu > Web Developer > Web Console (Ctrl+Shift+K)

2. Once it opens, clear the Web Console output, copy and paste the JavaScript command, and press Enter button on the keyboard to see the result on your screen.

running JavaScript in Firefox

Final words:

You can’t just copy and paste and execute JavaScript code in Firefox, Chrome, and Micorsoft Edge address bar. There are security constraints in place to protect your device from malicious code. Here is how to run JavaScript commands in the console of web browsers.

Have you found this tip useful? Let us know in the comments.

Related articles

Chrome Dev Tools: Resources Tab renamed to Application

Firefox 52 devtools: New Responsive Design Mode

Vivaldi 1.10 docks Developer Tools to the main window