Return to Snippet

Revision: 1048
at September 4, 2006 17:37 by Corhol


Initial Code
// addEvent() by John Resig
// http://ejohn.org/projects/flexible-javascript-events/
function addEvent ( obj, type, fn ) {
    if ( obj.addEventListener ) {
        obj.addEventListener ( type, fn, false );
    } else if ( obj.attachEvent ) {
        obj["e"+type+fn] = fn;
        obj[type+fn] = function ( ) { obj["e"+type+fn] ( window.event ); }
        obj.attachEvent ( "on"+type, obj[type+fn] );
    }
}

Initial URL

                                

Initial Description

                                

Initial Title
addEvent() by John Resig

Initial Tags
javascript

Initial Language
JavaScript