There was a scripting error on this page. While it is being addressed by site editors, you can view partial content below.

{{ DomRef }}


An event handler for the load event of a window.


window.onload = funcRef;
  • funcRef is the handler function to be called when the window's load event fires.


window.onload = function() {
<!doctype html>
    <title>onload test</title>
      function load() {
        alert("load event detected!");
      window.onload = load;
    <p>The load event fires when the document has finished loading!</p>


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 are also Gecko-Specific DOM Events like DOMContentLoaded and DOMFrameContentLoaded (which can be handled using EventTarget.addEventListener()) which are fired after the DOM for the page has been constructed, but do not wait for other resources to finish loading.


This event handler is specified in HTML.

See also

Document Tags and Contributors

 Contributors to this page: teoli
 Last updated by: teoli,