Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set breakpoint in Firebug on alert()?

I have a very complex website and I know that somewhere is an alert() with a description. Is there a way to set a breakpoint on the alert() call? The HTML is generated, so I cannot just grep for the message.

like image 746
Pan Bydlak Avatar asked Oct 21 '14 13:10

Pan Bydlak


2 Answers

You can use the console to replace the alert function:

window.alert = function() { debugger; };
like image 135
SLaks Avatar answered Sep 29 '22 10:09

SLaks


Firebug's Script panel allows you to search for code throughout all your JavaScript sources.

Firebug *Script* panel search for <code>alert(</code>

So you can simply search for alert( or search for the message that the alert box shows and set a breakpoint on the line where it's called.

Another way is to use the Break On Next button ( *Break On Next* button in Firebug's *Script* panel ) to stop at the next JavaScript statement that gets executed. So, click the button and then do the action that causes the alert box to be displaced.
Note: This only works if there are no other event handlers called before the event showing the alert box.

like image 27
Sebastian Zartner Avatar answered Sep 29 '22 08:09

Sebastian Zartner