Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome/Firefox set breakpoint on all javascript onclick events at once

I am trying to debug a third-party HTML/Javascript page but I can't easily locate the script entry points to set breakpoints on them.

I want the debugger to break on any element's onclick event handler. At the moment if the page is set up with something like

document.getElementById("foo").onclick = bar;

then in general it isn't easy to determine that foo and bar are connected.

So, I want to break on all onclicks, wherever they may be.

Can I do this in Chrome or Firefox?

like image 365
spraff Avatar asked Oct 01 '13 09:10

spraff


People also ask

How do you put a breakpoint in all methods?

Press F3 and then press F9 to add a breakpoint.

How do I set breakpoints in Firefox?

You can set an unconditional breakpoint using the context menu (see above), or by: Clicking on the line number for the line you want to break at in the source pane. Highlighting the line you want to break at in the source pane and pressing Ctrl + B (Windows/Linux) or Cmd + B (macOS).


1 Answers

Chrome:

Chrome inspector -> sources -> Event Listener Breakpoints

Firefox: get EventBug

You can read a bit more about eventBug in here: Using Firefox, how can I monitor all JavaScript events that are fired?

like image 154
Adam Zielinski Avatar answered Sep 21 '22 02:09

Adam Zielinski