Created
January 22, 2011 15:22
-
-
Save Nutrox/791176 to your computer and use it in GitHub Desktop.
JavaScript - DOM Ready
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
// | |
// Works in Chrome, Firefox, MSIE, Opera and Safari. | |
// | |
function onDOMContentLoaded( event ) { | |
if( event ) { | |
document.removeEventListener( event.type, onDOMContentLoaded, false ); | |
} | |
document.onreadystatechange = null; | |
// do something here... | |
} | |
if( document.addEventListener ) { | |
document.addEventListener( "DOMContentLoaded", onDOMContentLoaded, false ); | |
} | |
document.onreadystatechange = function() { | |
if( document.readyState == "complete" ) { | |
onDOMContentLoaded( null ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment