Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q509 How can I load a popup window when a user leaves my site, even if the user types in a url, selects a bookmark, clicks on the back button, or selects a url from the history?

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>

Feedback on 'Q509 How can I load a popup window when a user leaves my site, even if the user types in a url, selects a bookmark, clicks on the back button, or selects a url from the history?'

©2018 Martin Webb