In jQuery, if I do this…
$('a').click(function(){
// Do something
});
…the click event is stored at $('a').data('events') and I can fetch it like so:
jQuery.each($('a').data('events'), function(i, event){
jQuery.each(event, function(i, handler){
if(handler.type.toString() == 'click')
{
// do something
}
});
});
An event that is attached via attachEvent or addEventListener will obviously not appear in $('a').data('events'). Is there anything I can iterate in its place? I assume they’re queued up somewhere, but I can’t find documentation to point me in the right direction.
If you can get code installed at the beginning of the page, you can record all subsequent listeners in your own data structure with this kind of hook: Why does Google +1 record my mouse movements?.
I know of no way to access the existing listeners.