HTML and CSS Reference
EXPLANATION ( CONTINUED )
The alert dialog box pops up when the page finishes loading.
This is a user-defined function that keeps track of the number of seconds that
have elapsed since the page was loaded.
The variable called sec is increased by one each time trackTime() is called.
This function is called when the page is exited or reloaded. It is the event that is
triggered by the onUnLoad handler on line 10.
When the document has finished loading, the onLoad event handler is triggered.
The onLoad event handler is an attribute of the <body> tag. The event handler is
assigned a function called now() that sets up a timer that will go off every second
while the page is opened. After a second passes another function called track-
Time() will keep updating a variable that stores the number of seconds that have
elapsed. The background attribute of the HTML <body> tag is set to an image of
The onUnLoad event handler is triggered when the user either leaves or reloads
the page. See Figure 13.5.
Figure 13.5 If you exit or click the reload button, this alert box appears.