Skip to content

Instantly share code, notes, and snippets.

@ddubson
Created August 18, 2011 00:59
Show Gist options
  • Save ddubson/1153043 to your computer and use it in GitHub Desktop.
Save ddubson/1153043 to your computer and use it in GitHub Desktop.
Attaching Event Listeners
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