0

How can I track/trace back to (or capture) the actual coding of "invisible" JavaScript functionality?

On a number of websites, I'll often find a button that does something, like submit a message, but when I hover the mouse over the button, there is either no link attached, or just a "#" left as the link.

Looking in the page's code, there usually isn't any surrounding Javascript near the location of the element that would give it its functionality.

How does one both trace what's actually happening when the button is clicked, and track to the source of where this functionality is implemented in the code? Surely, there must be a quicker, more effective way than manually searching all the code and external Javascript files for any specific reference to the element (like the button)...?

(For reference, I'm using Firefox w/ Firebug)

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Coldblackice
  • 3,450
  • 4
  • 21
  • 22
  • possible duplicate of [How to find event listeners on a DOM node?](http://stackoverflow.com/questions/446892/how-to-find-event-listeners-on-a-dom-node) – Patrick Evans Jul 27 '13 at 17:29

1 Answers1

0

I am not sure about FireBug, but if you debug using Chrome, you can do the following:

  1. Open the Developer View (Ctrl+Shift+J)
  2. Go to the 'Elements' Tab and select your button
  3. On the Properties (to the right), scroll down to "Event Listeners".
  4. Look for the "click" event and expand it

There you have a link to the code that will run when the button is pressed.

Niv Noach
  • 41
  • 4