please dont rip this site

JavaScript: The Definitive Guide

Previous Chapter 21
JavaScript Reference
Next
 

Window.onload() Handler

Name

Window.onload() Handler---executed when a document finishes loading

Availability

Navigator 2.0, Internet Explorer 3.0

Synopsis

<BODY    a definition of the handler
    [ onLoad="JavaScript statements" ]
        ...
>
<FRAMESET    another way to define the handler
    [ onLoad="JavaScript statements" ]
       ...
>
window.onload=handler-func  defining the handler directly
window.onload();  an explicit invocation of the handler

Description

onload() is an event handler invoked by the browser when a document or frameset is completely loaded into the browser. The onload() handler is defined by the onLoad attribute of the <BODY> or <FRAMESET> HTML tags. The value of this attribute may be any number of JavaScript statements, separated by semicolons.

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 forms and other document elements have been parsed and are available through the Document object.

Usage

If any of your document's event handlers depend on the document being fully loaded, you should be sure to check that it is loaded before executing those handlers. If the network connection were to stall out after a button appeared in the document, but before the parts of the document that the button relied on were loaded, then when the user clicks the button they will get unintended behavior or an error message. One good way to verify that the document is loaded is to use the onload() handler to set a variable, loaded, for example, to true, and to check the value of this variable before doing anything that depends on the complete document being loaded.

Bugs

JavaScript is supposed to guarantee that the onload() handler for each frame in a window will be invoked before the onload() handler for the window itself. Unfortunately, Navigator 2.0 does not always do this. Thus in a framed document, you may need to check that each of your individual frames has fully loaded.

See Also

"Window", "Window.onunload()"


Previous Home Next
Window.onfocus() Book Index Window.onunload()

HTML: The Definitive Guide CGI Programming JavaScript: The Definitive Guide Programming Perl WebMaster in a Nutshell

file: /Techref/language/java/script/definitive/refp_451.htm, 6KB, , updated: 2019/10/14 15:00, local time: 2024/11/22 20:38,
TOP NEW HELP FIND: 
18.119.113.79:LOG IN

 ©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE!

<A HREF="http://sxlist.com/techref/language/java/script/definitive/refp_451.htm"> [Chapter 21] Reference: Window.onload()</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type a nice message (short messages are blocked as spam) in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.


Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?

 

Welcome to sxlist.com!


Site supported by
sales, advertizing,
& kind contributors
just like you!

Please don't rip/copy
(here's why

Copies of the site on CD
are available at minimal cost.
 

Welcome to sxlist.com!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .