You are here: irt.org | FAQ | JavaScript | Window | Q509 [ previous next ]
This question was asked and eventually answered by Pierre Adriaans:
I actually figured out how to do it. Use a frameset, make your whole site sit in the one and only frame defined from the index.html, and use the onUnload() handler on the frameset, not the frame. This way, it wont get triggered when you go forward (going forward takes place in the frame, withing the same frameset), but will get triggered if:
* the back button is clicked
* a new URL is typed
* the browser is closed
<html> <head> <script language="JavaScript"><!-- function unload() { window.open('popup.htm'); } //--></script> </head> <frameset rows="100%,*" onUnload="unload()" scrolling="no" border="0" frameborder="no" framespacing="0"> <frame src="main.html" name="the_main" scrolling="auto" border="0" frameborder="0"> </frameset> </html>