Skip to content

Instantly share code, notes, and snippets.

@ruthenium
Created June 27, 2014 17:33
Show Gist options
  • Save ruthenium/ab9bae61df2e89d60794 to your computer and use it in GitHub Desktop.
Save ruthenium/ab9bae61df2e89d60794 to your computer and use it in GitHub Desktop.
//////////////////
////ATTACH EVENT LISTENER
/////////////////
function attachEventListener(eventTarget, eventType, eventHandler) {
if (eventTarget.addEventListener) {
eventTarget.addEventListener(eventType, eventHandler, false);
} else if (eventTarget.attachEvent) {
eventType = "on" + eventType;
eventTarget.attachEvent(eventType, eventHandler);
} else {
eventTarget["on" + eventType] = eventHandler;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment