Visit Mozilla.org

DOM:window.onload

z Mozilla Developer Center, polskiego centrum programistów Mozilli.

« Dokumentacja Gecko DOM

UWAGA: Tłumaczenie tej strony nie zostało zakończone.
Może być ona niekompletna lub wymagać korekty.
Chcesz pomóc? | Dokończ tłumaczenie | Sprawdź ortografię | Więcej takich stron...

Spis treści

[edytuj] Podsumowanie

Uchwyt zdarzenia dla zdarzenia wczytywania okna (window).

[edytuj] Składnia

window.onload = funcRef;
  • funcRef jest funkcją uchwytu.

[edytuj] Przykład

window.onload = function() {
  init();
  doSomethingElse();
};
<html>
<head>

<title>Test onload</title>

<script type="text/javascript">

window.onload = load;

function load()
{
 alert("Wykryto wczytanie zdarzenia!");
}
</script>
</head>

<body>
<p>Wczytywane zdarzenie odpalane jest, kiedy dokument zostanie wczytany!</p>
</body>
</html>

[edytuj] Uwagi

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 DOMContentLoaded event (which can be handled using addEventListener) which is fired after the DOM for the page has been constructed, but doesn't wait for other resources to finish loading.

[edytuj] Specyfikacja

DOM Level 0. Nie jest częścią żadnego standardu.