January 2001
Beginner
312 pages
6h 4m
English
Okay, so you know about four events, but how do you use them? Well, let's start with the onLoad event.
To use the onLoad event to trigger a JavaScript function, you must place the following event handler in the <body> tag of the Web page:
<body onLoad="functionname()">
NOTE
An event handler is a piece of code that handles the event and does something as a result of it occurring, such as running a JavaScript function.
All you now must do to trigger the yourMessage() function is type its name between the double quotes of the event handler—for example, <body onLoad="yourMessage()">. Now, save the page and load it into the browser window:
<html> <head> <title>A Simple Page</title> <script language="JavaScript"> ...
Read now
Unlock full access