Question

I found this little bit of code over at devloper.Mozilla. addEventListener compatibility

Does that code on that page look like it's viable to make addEventListener cross browser?

I don't really have any access to a bunch of old browsers to test it so I thought I'd ask here first.

All new browsers support addEventListener so it's not too big of a deal. I'm just interested in what's available to provide functionality to old browsers and if Mozzilla's shim is worthy.

I like libraries like jQuery, YUI and prototype, and I know that's an option to make events easier(as it is with all js libraries) so think of this question as academic. For the spirit of learning.

Was it helpful?

Solution

The code you've linked to looks decent and as far as I know it should work. If I were you however I would start by diving into jQuery source to look for how they are doing it, since jQuery is under constant development, unlike (assuming) example from developer.Mozilla.

Replace jQuery with any other library you're feeling comfortable with looking into.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top