I was never a fan of doing anything to the HTML onLoad as this can be problematic.
The window loader object is slightly less bad in as much as it will fire when the DOM page structure has loaded
download form sourceforge.net
You should see red and green indicators showing if the DOM as loaded (just the HTML) and the window (the HTML and all the assets, images etc...)
Put the loader.js in to the head of your HTML page before any other js files
<script src="js/loader.js" type="text/javascript"></script>
Create and pass in any functions you want to run. Most of the time you'll be using the oncontentready method, the onload method is commonly used for preloading images and other assets you want to have ready if the user requests them. You wouldn't use oncontentready to preload images as the page is still busy loading assets
// Does the useagent have required js support? window.jsActive = (window.attachEvent || window.addEventListener) ; // useragent is ok and window.loader exists if (window.jsActive && window.loader){ window.loader.oncontentready(showDomLoad); window.loader.onload(showWindowLoad); // add more functions //loader.oncontentready(myotherfunction); //loader.onload(myotherfunctionLoad); }
Download this javascirpt object
text
tbc