/ Published in: JavaScript

Snatched this from another post and fixed something I found was not working.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
// Cross-browser implementation of element.addEventListener() function listen(evnt, elem, func) { if (elem.addEventListener) // W3C DOM elem.addEventListener(evnt,func,false); else if (elem.attachEvent) { // IE DOM var r = elem.attachEvent("on"+evnt, func); return r; } else window.alert('I\'m sorry Dave, I\'m afraid I can\'t do that.'); } // Use: listen("event name", elem, func);
Comments
