window.onload = function() {
init();
doSomethingElse();
};
<html>
<head>
<title>onload test</title>
<script type="text/javascript">
window.onload = load;
function load()
{
alert("load event detected!");
}
</script>
</head>
<body>
<p>The load event fires when the document has finished loading!</p>
</body>
</html>
The load event fires at the end of the document loading process. At this point, all of the objects in the document are in the DOM, and all the images and sub-frames have finished loading.
There is also Gecko-Specific DOM Events like DOMContentLoaded and DOMFrameContentLoaded events (which can be handled using addEventListener) which are fired after the DOM for the page has been constructed, but don't wait for other resources to finish loading.
Page last modified 01:38, 10 Oct 2007 by BijuGC