Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

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?

irt.org | Knowledge Base | JavaScript | Window | Q509 [ previous next ]

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?

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?'


Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.