Example #1
Example of using the body tag's events: onLoad() & onUnload().
Click here - if you came to this page
from a search engine. This page was designed to be viewed in a series of
training pages.
This pages functionality: (Look at the HTML source's JavaScript)
- Look at the HTML source. The body tag calls fonLoad() when the page
loads and fonUnload() when the page unloads.
- fonLoad() function creates a popup message using the alert() function.
- fonUnload() function creates a popup message using the alert() function,
then creates a new window with ex_window_bodytab_load2.htm as the web page.
Differences using IE vs Netscape: (I'm using IE 5.5 & NS 4.7)
- onLoad() event's alert() function works in both IE & Netscape.
- onUnload()
- If browser window is closing, event's work in IE,
but do not work in
Netscape.
- If browser is changing URL's but is still open, event's work with IE & Netscape.
- Netscape note - as long as the window is open, when pages are
unloaded Netscape will call the onUnload() event.
Do the following to test:
- Close the browser window by clicking on the "X" in the upper
right corner.
- Goto another URL by typing in your favorite site.
- Goto another URL by clicking on this link: www.yahoo.com