45

How can I trace all Javascript events of a web page?

Is there a possibility to trace all events, even such without a handler attached?

Is there any tool out there, that can do this?

Clarification:

For example:

For a text input I can add an event handler for onblur and onchange.

If I (in the browser) change the value of the textfield and leave it, both eventhandlers are executed. Now I would like to know which other events I "have missed" (the ones which would have been executed if there was an eventhandler attached).

Clarification2:

Can I get a list(on a given element) of all possible events I can attach an eventhandler?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Daniel Kreiseder
  • 12,135
  • 9
  • 38
  • 59
  • This is what I use: http://www.java2s.com/Code/JavaScript/Event-onMethod/CatalogEvent-onMethod.htm – Devin Rhode Nov 15 '11 at 19:39
  • > ###Similar to: [http://stackoverflow.com/questions/570960/how-to-debug-javascript-jquery-event-bindings-with-firebug-or-similar-tool](http://stackoverflow.com/questions/570960/how-to-debug-javascript-jquery-event-bindings-with-firebug-or-similar-tool) – Ramesh Soni Oct 21 '09 at 07:54

5 Answers5

62

Here is a list of Javascript events: https://developer.mozilla.org/en-US/docs/Web/Events

meeech
  • 1,396
  • 13
  • 21
34

Here's a simple script to log all available events in the browser's console:

var ev = '',
    out = [];
for (ev in window) {
    if (/^on/.test(ev)) { 
        out[out.length] = ev;
    }
}
console.log(out.join(', '));

Of course you'll get only the events of the browser you're currently using.

Simone
  • 20,302
  • 14
  • 79
  • 103
15

This is my favorite reference, it is updated more frequently than some of the other posts: https://developer.mozilla.org/en-US/docs/Mozilla_event_reference?redirectlocale=en-US&redirectslug=DOM%2FDOM_event_reference

Simone
  • 20,302
  • 14
  • 79
  • 103
joeyhoer
  • 3,587
  • 1
  • 19
  • 23
3

You can use FireBug Profiling Tool on FF and Web Developer Tool on IE8 or Developer Tools on WebKit

EDIT:

Just curious though, what do want to do with those events?

jerjer
  • 8,694
  • 30
  • 36
1

A simpler version of @simone's answer:

for (var event in window) {
  if (/^on/.test(event)) { 
    console.log(event);
  }
}
ckhatton
  • 1,359
  • 1
  • 14
  • 43