Forked from carldanley/facade-pattern-example-1.js
Last active
September 3, 2015 11:39
-
-
Save arturparkhisenko/33ee73cb31e9a774a914 to your computer and use it in GitHub Desktop.
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
// a simple facade that masks the various browser-specific methods | |
function addEvent( element, event, callback ) { | |
if( window.addEventListener ) { | |
element.addEventListener( event, callback, false ); | |
} else if( document.attachEvent ) { | |
element.attachEvent( 'on' + event, callback ); | |
} else { | |
element[ 'on' + event ] = callback; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment