Created
August 23, 2011 19:28
-
-
Save dperini/1166240 to your computer and use it in GitHub Desktop.
Feature testing browser support for 'load' events
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
<script type="text/javascript"> | |
// 'load' events should be supported by every browser | |
// this was just an exercise to find a way to test it | |
var isLoadSupported = 'onload' in window, loadHandler = window.onload; | |
document.createElement('body').setAttribute('onload', 'return'); | |
isLoadSupported = isLoadSupported || typeof window.onload == 'function'; | |
window.onload = loadHandler; | |
window.addEventListener('DOMContentLoaded', function(e) { | |
alert(e.type + " - " + isLoadSupported); | |
}, false); | |
window.addEventListener('load', function(e) { | |
alert(e.type + " - " + isLoadSupported); | |
}, false); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment