Opening a Pop-Up Window that Closes When Its Parent Document is Unloaded

This document should open a smaller window as soon as it's loaded. When the contents of this window changes (e.g., you click the Back button, or enter a different URL) the smaller window should disappear.

This is all accomplished through the use of the onLoad and onUnload events. The challenge that must be overcome is that any variables declared in the onLoad event handler are destroyed before the onUnload event handler gets a chance to use them. To solve this problem you need to have a global variable declared (in this case, it's called newWin) to act as the handle to the window object you create in the onLoad event handler. Global variables can be accessed as long as the document is in the window, so there's no problem passing them from event handler to event handler.

Back to my workshop.