Nossos voluntários ainda não traduziram este artigo para o Português (do Brasil) . Junte-se a nós e ajude a fazer o trabalho!
An event handler for the load
event of a window
.
Syntax
window.onload = funcRef;
funcRef
is the handler function to be called when the window'sload
event fires.
Examples
window.onload = function() { init(); doSomethingElse(); };
<!doctype html> <html> <head> <title>onload test</title> <script> function load() { console.log("load event detected!"); } window.onload = load; </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, scripts, links 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.
Specifications
Specification | Status | Comment |
---|---|---|
WHATWG HTML Living Standard The definition of 'onload' in that specification. |
Living Standard | Initial definition |
See also
DOMContentLoaded
event in Listening to events: Simple DOM events
Etiquetas do documento e colaboradores
Etiquetas:
Colaboradores desta página:
cvrebert,
Robg1,
Sebastianz,
teoli,
MHasan,
nighca,
Havvy,
kscarfone,
Sheppy,
pimmhogeling,
trevorh,
Ms2ger,
gingacodemonkey,
another_sam,
Yanmorin,
BijuGC,
Niczar,
Ptak82,
Pmash,
Jabez,
Nickolay,
Wkinney,
BenoitL,
Rappo
Última atualização por:
cvrebert,