Created
November 24, 2011 02:20
-
-
Save oscar-reales-interactiv4/1390489 to your computer and use it in GitHub Desktop.
js: unobstrusive onLoad script
This file contains hidden or 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 addEvent(obj, evType, fn){ | |
| if (obj.addEventListener){ | |
| obj.addEventListener(evType, fn, false); | |
| return true; | |
| } else if (obj.attachEvent){ | |
| var r = obj.attachEvent("on"+evType, fn); | |
| return r; | |
| } else { | |
| return false; | |
| } | |
| } | |
| addEvent(window, 'load', foo); | |
| addEvent(window, 'load', bar); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment