Pop-up Marketing & Pop up Javascript codes

No Comments » Written on March 29th, 2012 by
Categories: Scripts

We have all came across pop-ups on the Internet, so from this point of view pop-ups need no introduction. However what many webmasters fail to know is that pop-up windows are an effective online marketing method that delivers much better results than banners for example. So if you are generating revenues from banners, you might do a bit better with pop-ups, as long as you are not over-abusing this method.

What does it mean to NOT over-abuse pop-up campaigns? Well it means to try to limit / cap the number of times someone sees your pop-up, for example once a day. We all know how annoying it can become to visit a website that launches pop-ups one after another, on any page load and reload. This can drive users away from your websites, however if the pop-up is caped at one / day, this will not interfere that much with visitors.

If you will start setting up pop-up marketing campaigns on your website, does that mean you should stop banner advertising or any other marketing messages? No, the other campaigns should continue running as before, and results might be better if all campaigns are converging to the same message (promoting same & similar services / products).

One pop-up script code to use in your website is below. This script is set to show a pop-up each time the page with the code loads (no limitations available). The code should be included in your web-page <body>…</body> tags. I personally put the code just before the closing </body> tag, as this way it allows the page content to load first before launching the pop-up window. Make sure you edit the PopUpURL.com with your pop-up link location.

Pop-up Each Time Code<SCRIPT language=JavaScript><!--
var Hitzone=window.open('http://www.PopUpURL.com','newWin','toolbar=yes,location=yes,status=1,menubar=yes, scrollbars=yes,resizable=0,width=800,height=600'); // -->

Alternatively, the pop-up window javascript code that can be capped for once a day can be found below. You should copy and paste the following code in a new file named onlyPopupOnce.js . Again, make sure you edit the PopUpURL.com with your pop-up link location.

Pop-up One Time JS Code Part 1var expDays = 1; // number of days the cookie should last

var page = "'http://www.PopUpURL.com";
var windowprops = "width=800,height=600,location=no,toolbar=no,menubar=no,scrollbars=no,resizable=yes";

function GetCookie (name) {
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen) {
var j = i + alen;
if (document.cookie.substring(i, j) == arg)
return getCookieVal (j);
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
return null;

function SetCookie (name, value) {
var argv = SetCookie.arguments;
var argc = SetCookie.arguments.length;
var expires = (argc > 2) ? argv[2] : null;
var path = (argc > 3) ? argv[3] : null;
var domain = (argc > 4) ? argv[4] : null;
var secure = (argc > 5) ? argv[5] : false;
document.cookie = name + "=" + escape (value) +
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
((path == null) ? "" : ("; path=" + path)) +
((domain == null) ? "" : ("; domain=" + domain)) +
((secure == true) ? "; secure" : "");

function DeleteCookie (name) {
var exp = new Date();
exp.setTime (exp.getTime() - 1);
var cval = GetCookie (name);
document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();

var exp = new Date();
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));

function amt(){
var count = GetCookie('count')
if(count == null) {
return 1
} else {
var newcount = parseInt(count) + 1;
return count

function getCookieVal(offset) {
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));

function checkCount() {
var count = GetCookie('count');
if (count == null) {
SetCookie('count', count, exp);
window.open(page, "", windowprops);
} else {
SetCookie('count', count, exp);


Once you have saved the file with above code, copy it to your hosting account where your website is located. The next step is to include the Script code in your website that will launch the pop-up window. For this you need to include the following code between the <head>…</head> tags of your web-page.

Pop-up One Time HEAD Code Part 2
<script type="text/javascript" src="onlyPopupOnce.js"></script>

Once implemented, you can test it and you will see that once the pop-up was launched, it will not show again until next day. To test it more time, make sure to delete your web browser cookies before each test.

Leave a Reply

To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Anti-spam image