Mozilla.com

  1. MDC
  2. Main Page
  3. DOM
  4. window.onload

« Gecko DOM Reference

Summary

An event handler for the load event of a window.

Syntax

window.onload = funcRef;
  • funcRef is the handler function.

Example

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>

Notes

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.

Specification

DOM Level 0. Not part of any standard.

Languages

Page last modified 01:38, 10 Oct 2007 by BijuGC

Files (0)