Sorry, not likely to happen (except as a security hole). Your in-page JavaScript is deliberately sandboxed and limited - it can interact with the page, and with the network through AJAX, but it cannot and should not interact with other things that happen in your computer - including the browser.
Answer from Piskvor left the building on Stack OverflowVideos
Sorry, not likely to happen (except as a security hole). Your in-page JavaScript is deliberately sandboxed and limited - it can interact with the page, and with the network through AJAX, but it cannot and should not interact with other things that happen in your computer - including the browser.
It is not clear why you need to provide such link. DevTools is not a tool for the end user. If you don't like keyboard shortcuts, then there is a page chrome://inspect/ which has the list of pages and extensions, and each entry has a link that opens devtools.
Also, you may use remote debugging page which opens devtools in a page. https://developers.google.com/chrome-developer-tools/docs/remote-debugging
When writing multiline JS in the dev console, you have to hit Shit+Enter to create a new line. However, sometimes I mess up and hit just Enter which executes the whole script. It's not a big deal for most scripts, but I am working with JS that sends data to an API, so accidental execution can be an annoyance. If I could change the shortcut to Ctrl+Enter to execute and use Enter to create a new line, that would be ideal.
if you don't want to explicitly create a js file but still want to test your javascript code, you can use snippets to run your JS code.
Follow the steps here:
- Open Dev Tools
- Go to Sources Tab
- Under Sources tab go to snippets, + New snippet
- Paste your JS code in the editor then run Command + Enter on a Mac, or Ctrl + Enter on Windows or Linux. You should see the output in console if you are using console.log or similar to test. You can edit the current web page that you have open or run scripts, load more javascript files. (Just note: this snippets are not stored on as a js file, unless you explicitly did, on your computer so if you remove chrome you will lose all your snippets);
- You also have a option to save as your snippet if you right click on your snippet.
Try this:
1. Install Node.js from https://nodejs.org/
2. Place your JavaScript code into a .js file (e.g. someCode.js)
3. Open a cmd shell (or Terminal on Mac) and use Node's Read-Eval-Print-Loop (REPL) to execute someCode.js like this:
> node someCode.js
Hope this helps!
Chrome
Opening the “Console” panel of Chrome’s DevTools:
Windows and Linux: Ctrl + Shift + J
Mac OS: Cmd + Opt + J
Note: In addition to the “Console” panel, there also exists a smaller slide-up console which can be toggled via Esc while any of the other panels is active.
Full documentation
Firefox
Opening the “Console” panel in Firefox’s Developer Tools:
Windows: Ctrl + Shift + K
Mac OS: Cmd + Opt + K
Note: In addition to the “Console” panel, there also exists a smaller slide-up console which can be toggled via Esc while any of the other panels is active.
Full documentation
Internet Explorer
Opening the “Console” panel in Internet Explorer’s F12 Developer Tools:
- F12, then click on the “Console” tab
Note: In addition to the “Console” panel, there also exists a smaller slide-up console which can be toggled via Ctrl + ` while any of the other panels is active.
Full documentation
Safari
Note: In order to view the console in Safari, you have to enable the “Show Develop menu in menu bar” setting in the “Advanced” pane of Safari’s preferences (screenshot).
Opening the “Console” panel in Safari’s Web Inspector:
- Cmd + Opt + C
Note: In addition to the “Console” panel, there also exists a smaller slide-up console which can be toggled via Esc while any of the other panels is active.
Full documentation
Opera
- Windows and Linux: Ctrl + Shift + I
- Mac : ⌘+⌥+I
Full documentation
To indirectly reach the Console in Opera (checked on v9.6) the shortcut is Ctrl+Shift+i while on Safari 5 (on Windows) it is Ctrl+Alt+i
I wish all the browser makers could get together to standardize the keyboard shortcuts.
Update: It appears that the REPL tab under the Scripts tab in Opera Dragonfly in Opera 11 is similar to the Console option that was available in previous Opera versions.
I did not found much documentation on REPL after a cursory search, except for this article which has an indirect reference.
I tried this command in REPL with the Google home page open & it executed fine i.e. it hid the Google logo - document.getElementById('logo').style.visibility = 'hidden';