onLoad & onUnLoad with Prompt


The user’s name is obtained by using the window.prompt() method.

The link and heading text were written to the page using the window.write() and window.writeln() methods.

This text has already been written, and you may even have had a chance to read it. But a window will soon open, welcoming you to the page.

The onLoad event activated the welcome() function after the entire page had loaded.

The onUnLoad event activates the goodbye() function when leaving the page.

The functions use the window.alert() method to display message boxes to the user.


Taken from:

Book: JavaScript by Example
Publisher: Que Publishing
Chapter: 4
Listing: 4.2
Additions by: R. Hinton