0

Is there a way I can set up javascripting in Chrome's console so that it does not process my statement as soon as I hit return. If I'm trying to test something out by just writing some javascript there, it processes before I'm done writing.

//here I am writing in the console

if ($(el).size() === 0){
   //now I hit return because I want to type some stuff if this evaluates to true
   //but return submits it as a finished piece of javascript and of course 
   //I get SyntaxError: Unexpected end of input before I can have a chance
   //to finish the logic

I know I can hit shift+return and get a line break, and though that's a small inconvenience, it's still a bit of an inconvenience. Is there anyway I can tell it to hold off processing until I hit a macro like shift+return?

It's the same way in Firebug. Maybe there's an option there. Or maybe someone knows of a good third party add-on. Thanks.

4

2 回答 2

4

In the comments I posted the ticket for the request for support, but it has been there for awhile. Chrome does have snipplets, but you have to enable them.

  1. In the address bar type about:flags
  2. Enable Developer Tools experiments
  3. Restart the browser
  4. Open the Developer Tools open the settings menu [gear on bottom right corner]
  5. Click the Experiments tab [on left], check Snippets support
  6. Restart the browser
  7. In the Scripts panel, there will be a Snippets tab, click on it.
  8. Right click on the area below and from context menu select New
  9. You can than Edit and Run the code like a file. Run it with the context menu or play button.
于 2013-06-26T20:08:22.713 回答
2

A multi-line console effectively lets you do what you want. Chrome has a request for this but is otherwise not really available.

Firebug Lite for Chrome does allow it. Just click the little red button at the bottom-right of the Javascript console.

Before After

于 2013-06-26T19:58:31.813 回答