Created
August 18, 2011 00:59
-
-
Save ddubson/1153043 to your computer and use it in GitHub Desktop.
Attaching Event Listeners
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function attachListener(type, id, func){ | |
var element = document.getElementById(id); | |
if(window.addEventListener){ // FF | |
element.addEventListener(type, func, false); | |
return true; | |
} else if(window.attachEvent){ // IE | |
element.attachEvent('on' + type, func); | |
return true; | |
} | |
else return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment