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/blog“);
}
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 siteGoodBye();
//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)
what the hell?
i can't copy those text..used chrome and firefox
Mark,
I regret the inconvenience created to you.
The website is coded in such a way to avoid text selection and content theft. this feature is enabled for most spammy geo locations based on IP. That could be the reason you could not copy for your use. I have your email adress, have emailed you a copy of what you were looking for.
Hope that helped you.
Cheers, Josh
Hello Joshu. I'm John and would like to have the code too. Can you send it to my email? Thanks for your consideration
Sure John,
It has been emailed to you!
Cheers, Josh
Hi Josh,
I would love the text also. I also tried to copy/paste it and couldn't…
Thank you so much,
Evelyn
Hi Josh,
it would be nice, if you can send me the code via mail
Thanks a lot
Bernhard
Dear all,
Now I have disabled the copy block script, anyone can directly copy from here now.
cheers
Josh
Hi Josh,
This looks like a fantastic script, but I'm having trouble getting it to work….
Is there something i'm missing? Is there anything I am supposed to change?
I have added the codes exactly as is to my website header and updated the body tag…
Thanks,
Victoria
It did work fine for me! Thanks for the great script and appreciate your help!
regards
Stacey
Valuable info. Fortunate me I discovered your web site by accident, and I am surprised why this accident did not came about in advance! I bookmarked it.
Hi Josh
Thanks for the tutorial first of all!
It works great with IE, but I can't get it to work with Google Chrome.. it seems to have something to do with the onunload event.. do you know of any complications with this script and Google Chrome?
Best regards,
-Daniel
Hey Dan,
It seems like it works for IE and Mozilla only. But nowadays we have plugins for CMS that works, why dont you try that way?
Regards
Josh
I'm really inspired together with your writing skills and also with the format in your blog. Is that this a paid subject matter or did you modify it yourself? Either way keep up the nice high quality writing, it's uncommon to see a nice blog like this one nowadays..
Can we paste this code in Html/JavaScript widget?
Can we put it in Html/jscript box???
Josh, your post was really helpful! Thanks for doing it. I am trying to create an exit message that appears only when a specific link is clicked. How would I modify this script to do that?
Dave