window.onload will light up after all images, frames and objects have finished loading onto the page. Your question is not clear enough about whether you want the script to wait for them, but if you do not, you will need a “finished document”.
First, many (all?) DOM-based Javascript frameworks provide this functionality, a cross-browser in the form of an event. jQuery example:
$(document).ready(function() { alert("DOM is ready"); });
If you want to do this without a frame, it becomes a little more uncomfortable. Most browsers (coughnotIE) provide a DOMContentLoaded event:
if (document.addEventListener) { document.addEventListener('DOMContentLoaded', function () { alert("DOM is ready"); }, false); }
For the IE part, this is the defer job in the script tag. You can use conditional comments to make sure that only IE parses the script:
source share