5

Possible Duplicate:
How to debug Javascript/jQuery event bindings with FireBug (or similar tool)
How to inspect an element's associated event handlers?

Sometimes,I use firebug to inspect a button in page, I found there is no onclick function. But actually it did have an event handler. I think it used "bind" method to attach event handler.

Now, my question is how can I use some tool and I can find out the event handler easily?

Community
  • 1
  • 1
Tom
  • 2,857
  • 9
  • 46
  • 59
  • It's really good if I am using jquery, but I am using ext-js, I still do not know how to trace the event handler of my button. I tried using document.getElementById("ext-gen41").onclick,but the result is undefined. – Tom Jul 21 '11 at 07:08
  • They could have placed the event handler in the body element, and then manually check "event.target' to see what element is clicked, these handlers are really hard to find (not sure why this got marked as a duplicate) – Ferrybig Mar 06 '19 at 14:00

2 Answers2

4

In google chrome it's really easy. There you can setup debuger so that it will stop execution whenever click event is fired:

enter image description here

Molecular Man
  • 22,277
  • 3
  • 72
  • 89
  • This sounds good, but I broke on click, no script appeared. – Tom Jul 22 '11 at 01:39
  • @Tom, as you can see from screenshot this method worked for me. The only thing I can suggest try to wait little longer. Sometimes chrome needs a lot of time to parse script, highlight it and render. And there are really huge scripts in extjs. So this may be an issue. – Molecular Man Jul 22 '11 at 05:20
0

I have a trick which could help you find what is triggered when you click on a button :

  • use chrome (might have similar option in safari or even in firefox using firebug but I don't know)
  • open the page you want to inspect (obviously :) ) and inspect anything in the page (right click, inspect this element)
  • go to the scripts tab
  • and click on the pause button (on right pane) and then click on your button
  • the code is now breakpointed where the js is triggered (you can then follow the flow and debug your code)
bobylito
  • 3,172
  • 22
  • 27