SuitsAbounding.com
08-07-2008, 04:13 PM
Hello,
I have located several codes for exit popups, but my problem is that they popup when customers navigate to other pages instead of only when they leave the site. My understanding is that the code does not distiguish between going to another page or leaving the site. Is there a way to modify this script with exceptions, such as popup except when "Continue" or "Back" buttons are clicked? Also the page I want to use this script on is www.suitsabounding.com/before_payment.asp
The ultimate goal is to offer customers that are leave my site a discount if they purchase today.
The code I am using is
<head>
<script language="JavaScript">
<!--
function CreateCookie(name, value, expiredays)
{
var todayDate = new Date();
todayDate.setDate(todayDate.getDate() + expiredays);
document.cookie = name + " = " + value + "; expires=" +
todayDate.toGMTString() + ";";
}
function ReadCookie(cookiename)
{
var numOfCookies = document.cookie.length;
var nameOfCookie = cookiename + "=";
var cookieLen = nameOfCookie.length;
var x=0;
while (x <= numOfCookies)
{
var y = (x + cookieLen);
if (document.cookie.substring(x, y) == nameOfCookie)
return(ExtractCookieValue (y));
x = document.cookie.indexOf(" ", x) + 1;
if (x == 0)
break;
}
return null;
}
function ExtractCookieValue(val)
{
if ((endOfCookie = document.cookie.indexOf(";", val)) == -1)
{
endOfCookie = document.cookie.length;
}
return unescape(document.cookie.substring(val, endOfCookie));
}
function GoodBye()
{
if (confirm("\nDON'T GO! We will give you an additional 10% off if you continue with your purchase today. Use coupon code TodayOnly\n"))
{
window.open("http://www.suitsabounding.com/before_payment.asp");
}
else
{
alert("\nGod Bless\n & we hope to see you again soon.\n");
return false;
}
}
function MainGoodBye()
{
var userCookie = ReadCookie("_chups");
if (userCookie == null)
{
// user is here at first time
//propose to visit site
GoodBye();
//create coockie key (30 days)
CreateCookie("_chups", 1, 30);
}
}
//-->
</script></head>
<body onunload="MainGoodBye()">
I have located several codes for exit popups, but my problem is that they popup when customers navigate to other pages instead of only when they leave the site. My understanding is that the code does not distiguish between going to another page or leaving the site. Is there a way to modify this script with exceptions, such as popup except when "Continue" or "Back" buttons are clicked? Also the page I want to use this script on is www.suitsabounding.com/before_payment.asp
The ultimate goal is to offer customers that are leave my site a discount if they purchase today.
The code I am using is
<head>
<script language="JavaScript">
<!--
function CreateCookie(name, value, expiredays)
{
var todayDate = new Date();
todayDate.setDate(todayDate.getDate() + expiredays);
document.cookie = name + " = " + value + "; expires=" +
todayDate.toGMTString() + ";";
}
function ReadCookie(cookiename)
{
var numOfCookies = document.cookie.length;
var nameOfCookie = cookiename + "=";
var cookieLen = nameOfCookie.length;
var x=0;
while (x <= numOfCookies)
{
var y = (x + cookieLen);
if (document.cookie.substring(x, y) == nameOfCookie)
return(ExtractCookieValue (y));
x = document.cookie.indexOf(" ", x) + 1;
if (x == 0)
break;
}
return null;
}
function ExtractCookieValue(val)
{
if ((endOfCookie = document.cookie.indexOf(";", val)) == -1)
{
endOfCookie = document.cookie.length;
}
return unescape(document.cookie.substring(val, endOfCookie));
}
function GoodBye()
{
if (confirm("\nDON'T GO! We will give you an additional 10% off if you continue with your purchase today. Use coupon code TodayOnly\n"))
{
window.open("http://www.suitsabounding.com/before_payment.asp");
}
else
{
alert("\nGod Bless\n & we hope to see you again soon.\n");
return false;
}
}
function MainGoodBye()
{
var userCookie = ReadCookie("_chups");
if (userCookie == null)
{
// user is here at first time
//propose to visit site
GoodBye();
//create coockie key (30 days)
CreateCookie("_chups", 1, 30);
}
}
//-->
</script></head>
<body onunload="MainGoodBye()">