I have been instructed by my commanders to create popunder windows that are only triggered when the user leaves the site (and not each time a page is unloaded). Yes, I know this is a faux pas, but while I cannot disobey an order, I did manage to at least inject some compromise and have these things display has popunders (vs. overs), and after the user leaves our site.
I've accomplished this by calling a function in the BODY tag (btw, there is only 1 file that has the BODY tag, and it is <include>'d with all pages):
<BODY onUnload="popunder()">
Here is the "popunder()" function in the <HEAD>:
var strMem=0
function popunder() {
if(window.name != 'exitwin' && strMem == 0) {
window.open ('window.focus();
}
}
The last component of this method is to insert the following into each link that you don't want to trigger a popunder:
<a href="pagename.asp" onClick="strMem=1">
SO, this works great except for when the user hits the Back, Forward, or Refresh button on their browser.
AT LONG LAST, MY QUESTION! :
How can I have a popunder only be triggered by the user leaving the site in question, and not by any other action (including Back, Forward, and Refresh)?
Thanks!
Keith
keith@generalvitamin.com
I've accomplished this by calling a function in the BODY tag (btw, there is only 1 file that has the BODY tag, and it is <include>'d with all pages):
<BODY onUnload="popunder()">
Here is the "popunder()" function in the <HEAD>:
var strMem=0
function popunder() {
if(window.name != 'exitwin' && strMem == 0) {
window.open ('window.focus();
}
}
The last component of this method is to insert the following into each link that you don't want to trigger a popunder:
<a href="pagename.asp" onClick="strMem=1">
SO, this works great except for when the user hits the Back, Forward, or Refresh button on their browser.
AT LONG LAST, MY QUESTION! :
How can I have a popunder only be triggered by the user leaving the site in question, and not by any other action (including Back, Forward, and Refresh)?
Thanks!
Keith
keith@generalvitamin.com