robe03
12-24-2003, 10:38 AM
I am trying to add a popup on window close that thanks the viewer for visiting the page. Most of the scripts I have found on the web offer this but the popup comes even when the back button is pressed or another link is accessed. Does anyone know a script that prompts a popup only on close, or is this script even possible.
Thanks for your help.
Immortal
12-24-2003, 10:44 AM
var leaving=alert('Thank you');
window.unload=leaving;
BestZest
12-24-2003, 11:19 AM
Sorry I can't help you much, but I can tell you that onUnload is called when ever the user leaves the page, whether they close the window, or just press the back button. So Immortal's answer above won't work.
If the window with you website in has been opened from another window, then you could get the opening window to check if the pop up window has been closed, and if it has, then open another pop up.
Another solution could be to open a popup window when the user first visits the site, and 'blur' it so that it goes behind the open windows. This way, when the user closes the window, they will be left with the thank you window.
BestZest
Happy Chrimbo!!!