Help With This PLEASE

olesh999

New member
Feb 8, 2008
643
6
0
Austin, TX
Hey Guys, quick question here.

I'm running the script below but Im facing a problem. This is the scripts that when users want to leave your page they get bombed with a little window saying "Are You sure you want to leave this site? Click Cancel to Stay or Continue to Leave"

The script is working fine, the problem comes when the visitor clicks a link on the site they get this window. I want to avoid this. I only want this window to show when the user clicks the close window X. Not when they click the "buy button" or affiliate links.

Does anyone know how to go around this?

Thank You guys in advance. The code is below if someone wants to use it.

Code:
<script type="text/javascript" language="javascript"> 
var areYouReallySure = false;
var internalLink = false;
function areYouSure() {
if (!areYouReallySure && !internalLink) {
areYouReallySure = true;
location.href="http://afflink.com"
return "*****************************************************\n\nBLAH BLAH BLAHBLAH BLAH BLAHBLAH BLAH BLAHBLAH BLAH BLAHBLAH BLAH BLAHBLAH BLAH BLAHBLAH BLAH BLAHBLAH BLAH BLAHBLAH BLAH BLAHBLAH BLAH BLAHBLAH BLAH BLAHBLAH BLAH BLAHBLAH BLAH BLAHBLAH BLAH BLAHBLAH BLAH BLAHBLAH BLAH BLAHBLAH BLAH BLAHBLAH BLAH BLAHBLAH BLAH BLAHBLAH BLAH BLAHBLAH BLAH BLAHBLAH BLAH BLAHBLAH BLAH BLAHBLAH BLAH BLAHBLAH BLAH BLAHBLAH BLAH BLAHBLAH BLAH BLAHBLAH BLAH BLAHBLAH BLAH BLAH\n\nPress **CANCEL** NOW to get the free trials.\n\n*****************************************************";
}
}
window.onbeforeunload = areYouSure;
</script>
 


Disregard your code. Use this instead.

Put this in the head of your page (and be sure to change the body tag)

HTML:
<head>
<script src="loadonexit.js" type="text/javascript"></script>
</head>
<body onbeforeunload="return ExitPage();">


Then create "loadonexit.js" and put the following code in it:

Code:
// JavaScript Document
var ShowExitPopup = true;
function ExitPage(){
    if (ShowExitPopup){ 
    ShowExitPopup = false;
    location.href = "http://www.YOURLINK.com/";
    return 'PUT WHAT YOU WANT IT TO SAY HERE';
}
}
Enjoy