On a web page are elements with click and/or keypress handlers. If I add a new one it would be executed after them. I need a way to add a new callback which is prepended to the event handler list, so that it is executed beforehand. How is that possible with jQuery?
Update
Why can't I just use jQuery's unbind method? I am injecting my jQuery code to any web page, so that i don't know if any and which JavaScript framework is used. I need a universal way to detect event handlers and prepend mine. (Before you ask, I'm building a "recorder" application that tracks the users actions to store them and to execute them later on.)
Update 2
I only use Firefox, no need for IE compatibility. I have to wait for the page to load completely, and after that my jQuery script will be invoked.
.addEventListener()
will be called in and no way to list what handlers have been bound. A single library (like jQuery) can work around this as long as you only bind events through the library, but I'm not sure how you could handle events bound through multiple libraries and/or plain JS. Unless you can override.addEventListener()
before any other code on the page is run so that other code binding events goes through your proxy? (Which still wouldn't help you for older IE...) – Mesdames