Thursday, March 31, 2011

The Onload Event Handler


Take a look at the on load event on the body tag of your document. It will run everything on the page, after the page has finished loading, including table elements, dividers, images, scripts, style sheets, multimedia files, etcetera.

Often it is necessary to perform some action on the page, for example, filling a form with information from a database table, displaying a list of information, or getting a value from a table for future reference.

Example:
In the on load event you can write; on load=javascript:getvalue();

You can program multiple events simply by adding semicolons.

Example:

If you need to program multiple events you can specify the functions in your onload event as follows;
onload=javascript:getvalue();javascript:displaylist()

The on load event handler becomes very useful when displaying dynamic information to different parts of your page. It is good to become familiar with this event, and use it to your advantage when designing your content.

No comments:

Post a Comment

Programming for the Web