safari and chrome javascript console multiline

JavascriptBrowserDebugging

Javascript Problem Overview


Firebug has a multiline feature in their console tool. Is there a way to get this functionality with the debugger tool in Safari/Chrome?

Javascript Solutions


Solution 1 - Javascript

Shift-Enter on Windows allows multi-line entry where Option-Enter works on Mac.

A more fully featured editor is in the works.

Solution 2 - Javascript

For Google Chrome, you can Sources >> Snippets >> + New Snippet in the Developer Console.

enter image description here

Once you have written your multi-line code, you can execute it with the enter image description here button or with Ctrl + Enter as mentioned on the button.

This is like a text-editor which has a host of keyboard shortcuts which you can find under Settings >> Shortcuts under Text Editor

enter image description here

Good Luck.

Solution 3 - Javascript

I recommend this:

  1. Write debugger; and hit Enter, in the console tab
  2. This takes you to the Sources tab; if not, make sure debugger breakpoints are active
  3. Now you can write whatever you want in the Sources tab, which acts like a full IDE with features like newline and indentation
  4. Select any part of your code to run, and right-click, choose Evaluate in console

Solution 4 - Javascript

http://code.google.com/p/chromium/issues/detail?id=35487

Not yet.

UPDATE: the status of the issue I linked to is now "fixed".

Solution 5 - Javascript

Try pressing option (shift on Windows) at the same time as return. Inserts a newline on Mac.

Solution 6 - Javascript

Shift + Enter seems to work in chrome browser. I am using ubuntu 12.04 as my operating system. Thanks to Mr Bester and Sam Dutton for their inputs.

Solution 7 - Javascript

It is simple ... place semicolons between your multilines and it will work in the console.

For example

if you have html like this

<div id="test">This is a test statement</div>

You could paste following in the console and it will work

var ourTest = document.getElementById('test'); alert(ourTest.innerHTML);

I hope it helped.

Solution 8 - Javascript

There is cool extension to chrome https://chrome.google.com/webstore/detail/bigconsole/klommbdmeefgobphaflhmnieheipjajm

It just add another tab named BigConsole and it allow multiline code execution

Solution 9 - Javascript

Try using the notepad (or someting else) and then copy/paste to the console, works for me!!!!

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionminimalpopView Question on Stackoverflow
Solution 1 - JavascriptMrBesterView Answer on Stackoverflow
Solution 2 - JavascriptAakashView Answer on Stackoverflow
Solution 3 - JavascriptSaeed NeamatiView Answer on Stackoverflow
Solution 4 - JavascriptTomas AndrleView Answer on Stackoverflow
Solution 5 - JavascriptScott HyndmanView Answer on Stackoverflow
Solution 6 - JavascriptBimalView Answer on Stackoverflow
Solution 7 - JavascriptS. A. MalikView Answer on Stackoverflow
Solution 8 - JavascriptPiotr GalasView Answer on Stackoverflow
Solution 9 - JavascriptOmar AlejandroView Answer on Stackoverflow