Name
Window.onload: event handler invoked when a document finishes loading â JavaScript 1.0:
Synopsis
Function onload
Description
The onload
property of a
Window specifies an event handler function that is invoked when a
document or frameset is completely loaded into its window or
frame.
The initial value of this property is a function that contains
the semicolon-separated JavaScript statements specified by the
onload
attribute of the <body>
or <frameset>
tags.
When the onload
event
handler is invoked, you can be certain that the document has fully
loaded, and therefore that all scripts within the document have
executed, all functions within scripts are defined, and all document
elements have been parsed and are available through the Document
object.
You can use Window.addEventListener(
)
or Window.attachEvent(
)
to register multiple event-handler functions for onload
events.
See Also
Window.onunload
; Manipulating the Document During Loading, âManipulating the Document
During Loading,â Example 17-7, Chapter 17
Get JavaScript: The Definitive Guide, 5th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.