How to display Exit Splash or Exit message for wordpress Blog or website

How to display Exit Splash or Exit message for wordpress Blog or website

On the web I have come across a number of request for a “working” method for displaying an Exit splash or an Exit javascript message . An exit splash is basically a browser based pop-up message that is shown using a simple java script function to convey a message to the user leaving the website, requesting to subscribe or stay for more offers. This method helps drastically to improve the website traffic and retain traffic. Also it helps as a very effective marketing strategy on the internet now-a-days. Below is a tutorial that helps you to achieve this in 2 steps.

Step 1: Copy the below script and paste inside the <head> </head> tags of your website or blog header. If it’s a wordpress blog, in the themes – > header.php would contain both the header and the body tags.

<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()
{

// This is what the prompt will ask the visitor when they leave your website.

if (confirm(” We would request you to sign up for the OrangeCopper Blog weekly newsletter before leaving – Click OK “))
{

// This is what the prompt will say if they choose to see what you asked above.

alert(” Thank you!  Please fill your email in top right corner form on the Blog page loading “);
window.open(“http://www.orangecopper.com“);
}
else
{

// This is what the prompt will say if they choose to not see what you asked

alert(” No Problem, see you again Good Luck! “);
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>

Step 2

Find the <Body>  tag in your webpage or blog header.php and replace it with

<body onunload=”MainGoodBye()”>

Upload and you are done!! (feel free to edit the exit messages marked in blue as per your requirement).

Note: I thought this could help you and save a lot of time and money as there are websites who even charge for plugins and scripts that is as simple as this. Cheers !!

Site Tool Center(script credit)

16 Comments

  1. mark February 4, 2011
    • Joshu February 4, 2011
  2. John February 4, 2011
    • Joshu February 4, 2011
  3. Evelyn February 16, 2011
  4. Bernhard February 21, 2011
  5. Joshu May 5, 2011
  6. Victoria August 15, 2011
  7. Stacey Abo September 27, 2011
  8. Tired of buying hund October 5, 2011
  9. Daniel October 6, 2011
    • Joshu October 7, 2011
  10. Link bids Webdirecto December 21, 2011
  11. Alex Fernandez March 8, 2012
  12. Alex Fernandez March 8, 2012
  13. David Sarnowski March 22, 2012