I am using the code below to implement 1 time entry and exit popup.
The entry popup works fine, but the exit popup opens even if you
browse from one page to the other on the same site. I want it to popup
only if the user closes the browser or goes to a different site.
What is the best way to implement this ?
var isNN, isIE, loadURLs=new Array(), loadTimes=new Array(), exitURL,
loadURLno=0, scriptID, cookieVRFY;
var exit = true;
//set by user
scriptID='nrScr ipt';
cookieVRFY=1;
AddLoad('entry. asp',1);
//AddExit('exit.a sp');
function AddLoad(sURL,iT ime)
{
loadURLs[loadURLno]=sURL;
loadTimes[loadURLno]=iTime;
loadURLno++;
}
function AddExit(sURL)
{
exitURL=sURL;
}
if (parseInt(navig ator.appVersion ) >= 4) {
if (navigator.appN ame == "Netscape") {
isNN = true;
} else {
isIE = true;
}
}
function errorIgnore(e) { return true; }
function openLoadWin() {
var oldtime=0,mywin s;
for (mywins=0;mywin s<loadURLno;myw ins++)
{
var winLeft = (screen.width)/3;
var winTop = (screen.height)/3;
setTimeout("win dow.open('" + loadURLs[mywins] + "','Loadwin " + mywins
+ " ','width=350,he ight=200,top=0, left=0,scrollba rs=no
,top = " + winTop + ", left = " + winLeft +"' );self.focus(); "
,(oldtime+loadT imes[mywins])*1000+10);
oldtime+=loadTi mes[mywins];
}
return true;
}
function openExitWin() {
if (exitURL!='')
{
var ExitWin = window.
open(exitURL,'E xitWin','width= 350,height=200, top=0
,left=0,scrollb ars=yes');
self.focus();
}
return true;
}
if ( (cookieVRFY!=1) || (document.cooki e.indexOf( scriptID+'Popup PRO='
)==-1) )
{
window.onerror = errorIgnore;
if (isNN) {
document.captur eEvents(Event.U NLOAD | Event.LOAD | Event.ERROR |
Event.CLICK);
}
openLoadWin();
//window.onunload =openExitWin;
if (cookieVRFY==1) {
document.cookie =scriptID+'Popu pPRO=HeyGuys!;p ath=/';
}
}