17

I am looking for something like Debugger.Launch() in .NET, which breaks into the debugger programmatically.

I am not looking for a cross browser way to do it, just Google Chrome is good enough.

Pierre Arnaud
  • 10,212
  • 11
  • 77
  • 108
mark
  • 59,016
  • 79
  • 296
  • 580
  • Possible duplicate of : http://stackoverflow.com/questions/66420/how-do-you-launch-the-javascript-debugger-in-google-chrome – DhruvPathak Feb 27 '12 at 09:41
  • 2
    It is similar, but I am looking for a programmatic way, so that the browser stops there automatically without any actions from me. The answer to that question talks about an interactive way, although there is a response which answers my question exactly. – mark Feb 27 '12 at 10:29

1 Answers1

24

Yes, you need to use:

debugger;

The script will break exactly at line where you put debugger keyword.

To view it, you will first need to open Tools -> Developer tools (or pressing F12) and then by selecting your file from Scripts tab.

Sarfraz
  • 377,238
  • 77
  • 533
  • 578