This web page is a frame (top & bottom) designed to show using the properties onLoad and onUnload in the <frameset> tag of the Frame Set html file. Click here to go to a page where you can download these examples (see Browse Window section)

This page should:

  1. (IE & NS) Popup an alert (onLoad) when the page loads.
  2. (IE & NS) Popup an (onUnload) alert then an (onLoad) alert if you refresh the window.
  3. onUnload when the window is closing.
    1. IE & NS 6.0 allows functions to be called in the onUnload when the window is closing.
    2. NS4.x does not execute the onUnload when the window is closing (works for Reload). This web page proves that.

Look at the Frame set's onLoad and onUnload properties in the tag: <frameset>

Sample <frameset> tag:

<html>
<head>
<title>
Frame: Onload & Onunload Examples</title>
<meta http-equiv=
"Content-Type" content="text/html; charset=iso-8859-1">
<script language
="JavaScript">
<!--
function testOnload() {
  alert('OnLoad: Alert in testOnload() executed by onLoad property of frameset tag.')
}
function testOnUnload() {
  alert('OnUnload: Alert in testOnUnload() executed by onUnLoad property of frameset tag.')
}
//-->

</script>
</head>
<frameset rows=
"80,*" frameborder="0" border="0" framespacing="0" 
  onLoad=
"javascript:testOnload()"   
  onUnload=
"javascript:testOnUnload(); alert('onUnload: alert in frameset tag')">
  <frame name="topFrame" scrolling="NO" noresize src="ex_window_frame_onload_unload_top.htm" >
  <frame name="mainFrame" src="ex_window_frame_onload_unload_bottom.htm">
  <noframes>
    <body bgcolor=
"#FFFFFF">
      <p>
Sorry, this page needs a browser that supports frames.</p>
    </body>
  </noframes>
</frameset>
</html>

HTML files involved:

I've tested this web page with the following browsers: