Programmatically stop JavaScript execution in Firebug
35,876
You can use the debugger
statement:
// your JS code
...
// break here
debugger;
It works in all major browsers.
![Admin](/assets/logo_square_200-5d0d61d6853298bd2a4fe063103715b4daf2819fc21225efa21dfb93e61952ea.png)
Author by
Admin
Updated on February 27, 2020Comments
-
Admin over 4 years
I am currently debugging complex JavaScript code with Firebug. I am looking for a way to stop the JavaScript execution as if it was a breakpoint programmatically.
Example:
instructions ... degugger.breakpoint(); // the execution stops here as if a breakpoint was // manually set other instructions ...
-
Kirtan almost 15 yearsIt will also work with IE if you enable Script Debugging in the Internet Options.
-
James Wiseman almost 15 yearsAfter you have done this, you should be then be able to use breakpoints in your IDE debugger. This saves you from having to declare multiple 'debugger;' lines of code across your application.
-
snapfractalpop over 10 yearsI'm surprised how long I've gone without realizing you could do this. Thanks, this is very helpful. I would add that, for Chromium on Linux, this line of code will only pause execution if the debugger is open (and the disable breakpoints toggle is not selected).
-
JonnyRaa almost 10 yearsthis didn't work for me in firefox. Do you have to have the debugger open? I had firebug open but was looking at the console + network tabs. I wasn't actually interested in the code/state at the time but just wanted the console output to stop
-
James Dunn about 9 yearsThe debugger directive now works in Opera. (Tested in Opera 28)