HTML and CSS Reference
In-Depth Information
To add the onload event handler to the clock Web page:
1. Within the <body> tag of the clock.htm file, insert the following attribute as shown
in Figure 11-5:
Figure 11-5
inserting the onload event handler
the NYClock() f function runs
when the page is initially
loaded by a browser
2. Save your changes to the file.
3. Reload clock.htm in your Web browser. The page opens, displaying the place-
holders you specified in the previous set of steps. See Figure 11-6.
Figure 11-6
Placeholder values in the web form
placeho l der date
and time values
placeholder values for
days, hours, minutes, and
seconds left in the year
altafulla/; jbdphotography/
Trouble? If you receive an error message when loading the page, check the code
in the NYClock() function and the onload event handler. Some common program-
ming errors that might occur within the NYClock() function include mismatching
uppercase and lowercase letters, misspelling variable names, forgetting to close
up double quotes, and forgetting to enclose command blocks and functions within
curly braces. Most browsers contain developer tools and debugging tools to help
isolate the source of such an error.
Now that you've seen how to run a function to set the date and time values on the
Web form, you'll next explore the properties and methods associated with Date objects.
Search WWH ::

Custom Search