In the course of building my project, I discovered that it's possible to overload the addEventListener
object - I've seen a few questions that asked the question about adding one eventListener
to multiple objects, but the questions are over two years old, and really, I just want to put out there a simple HOWTO so others might find it...how do I do that? Is this the place for it?
(Still with the noob questions, I know...)
var old = Element.prototype.addEventListener; Element.prototype.addEventListener = function() { /*...*/ };
(example) and then do what you want to do. Should work on IE9 and up and anything modern. :-) (And on IE8, you could add it, IE8 does haveElement.prototype
.)useCapture
was optional and you need to run it on some older browser that requireduseCapture
. :-) Not necessarily a good reason, but...useCapture
being optional, or needing to track all calls to it, are just about the only use cases I can think of, both of which are better handled with a wrapper.