Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to trace or debug all available javascript events

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?

like image 933
Daniel Kreiseder Avatar asked Oct 21 '09 07:10

Daniel Kreiseder


People also ask

How do you find out which JavaScript Events fired?

Open Google Chrome and press F12 to open Dev Tools. Go to Event Listener Breakpoints, on the right: Click on the events and interact with the target element.

What does the JavaScript debugger statement do?

The debugger statement in JavaScript is used for setting a breakpoint in the code. The code stops execution as soon as it encounters the debugger statement and calls the debugger function (if available).

Which JavaScript function is most useful for finding errors?

log() is a good way to debug errors but setting breakpoint is a faster, efficient and better method. In this method, Breakpoints are set in code which stops the execution of code at that point so that the values of variables can be examined at that time.


Video Answer


2 Answers

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

like image 168
meeech Avatar answered Oct 02 '22 09:10

meeech


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.

like image 33
Simone Avatar answered Oct 02 '22 10:10

Simone