/ Published in: JavaScript

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
// 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] ); } }
Comments
