There seem to be endless pages of writing and comment threads about addEvent implementations in Javascript, going back many years.
What should I be using today, in currentTime.getFullYear(), for the most versatile, simple cross-browser addEvent implementation? What is the best practice? Is there a standard anywhere on the horizon?
Is google’s base2 library a panacea for this problem?
Background:
Crossbrowser DOM Scripting: Event Handlers
addEvent() considered harmful
addEvent() recoding contest
Flexible Javascript Events
A problem with John Resig’s addEvent
addEvent() – My Solution
IE9+ all support
window.addEventListenersee https://developer.mozilla.org/en-US/docs/DOM/element.addEventListenerTo support everyone else you have to do some fanciness to support both it and
window.attachEvent.See: https://stackoverflow.com/a/6925427/496735