Listen for all events in JavaScript -
i'm trying figure out how listen events on javascript object.
i know can add individual events this
element.addeventlistener("click", myfunction); element.addeventlistener("mouseover", myfunction); ...
i'm trying figure out if there catch-all, i'd this:
// begin pseudocode var myobj = document.getelementbyid('someid'); myobj.addeventlistener(/*catch all*/, myfunction); function myfunction() { alert(/*event name*/); } // end pseudocode
to pick standard element's events.
var myobj = document.getelementbyid('someid'); for(var key in myobj){ if(key.search('on') === 0) { myobj.addeventlistener(key.slice(2), myfunction) } }
but @jeremywoertink mentioned other events possible.
Comments
Post a Comment