admin管理员组

文章数量:1330564

I am trying to debug someone else's UI implementation, and it is really hard at this point to know what events are calling which functions.

Is there a way to know what function was called when I trigger an event? Maybe with Firebug?

I am trying to debug someone else's UI implementation, and it is really hard at this point to know what events are calling which functions.

Is there a way to know what function was called when I trigger an event? Maybe with Firebug?

Share Improve this question asked Mar 12, 2012 at 2:47 Nic HubbardNic Hubbard 42.2k66 gold badges253 silver badges415 bronze badges 6
  • Are the events attached to inspectable DOM elements? – Dagg Nabbit Commented Mar 12, 2012 at 3:11
  • That is what I can't figure out. – Nic Hubbard Commented Mar 12, 2012 at 3:21
  • How do you trigger the events? By clicking things, moving the mouse, etc? – Dagg Nabbit Commented Mar 12, 2012 at 3:22
  • It is a click event, but I can't find a reference to what that is bound to. – Nic Hubbard Commented Mar 12, 2012 at 3:27
  • In that case it's probably bound to window or document (assuming it happens when you click anywhere). I was going to suggest selecting the element and looking in the "Event Listeners" panel, but I guess that won't help. – Dagg Nabbit Commented Mar 12, 2012 at 3:36
 |  Show 1 more ment

3 Answers 3

Reset to default 4

In chrome developer toolbar you can set event breakpoints. - hope this will help

There's an extension to Firebug called EventBug. There are actually quite a few extensions to Firebug that are awesome.

http://getfirebug./wiki/index.php/Firebug_Extensions#Eventbug

EventBug lets you see the event functions that are attached to an element and set breakpoints in their handlers.

You may also try to use Firebug's "Break on next" feature when in Script Tab. After enabling it, it will break whenever some script is going to be executed.

This however has a disadvantage that if you use a framework that is listening to mouse events globally (e.g. bound to <body>), you will get a break point whenever you move your mouse, so then it's pletely useless.

Also, when there is some timeout set that fires before you manage to create your event (e.g. mouse click), the break will occur on that timeout.

本文标签: javascriptDebug which function was fired using FirebugStack Overflow