Skip to content

Instantly share code, notes, and snippets.

@iamnewton
Created January 16, 2014 04:46
Show Gist options
  • Save iamnewton/8449931 to your computer and use it in GitHub Desktop.
Save iamnewton/8449931 to your computer and use it in GitHub Desktop.
Retrieves a list of all possible DOM events and populates an array. Works in IE9+, Chrome, Safari & Firefox.
Object
.getOwnPropertyNames( document )
.concat(
Object.getOwnPropertyNames(
Object.getPrototypeOf(
Object.getPrototypeOf( document )
)
)
)
.concat(
Object.getOwnPropertyNames(
Object.getPrototypeOf( window )
)
)
.filter( function( i ) {
return ! i.indexOf( 'on' ) && ( document[i] == null || typeof document[i] == 'function' );
})
.filter( function( elem, pos, self ) {
return self.indexOf( elem ) == pos;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment