Link to home
Start Free TrialLog in
Avatar of kwaoc
kwaoc

asked on

Creating a pop up

Hi folks,
I was looking for help from someone to tell me how to do a pop up window for my site.
When someone clicks on a web page, ie info page, a pop up window will appear and it will allow them to sign up to a mailing list.
How do I do this? I used the code from a pop up generator software but when I tested it out, it wouldnt pop up!
Where does the code go?

All the best,
Kwaoc
ASKER CERTIFIED SOLUTION
Avatar of taydui
taydui

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kwaoc
kwaoc

ASKER

If someone signs up for the newsletter, will this pop up still keep coming up on their pc when they visit my site again?
 In that case, you have to use cookies to mark if that user signed up your newsletter or not.
Hi,

Here's a script you can use to make a window popup only once. It's from the SimplyTheBest website.

You can adjust it according to your needs.

-------------

<SCRIPT LANGUAGE="JavaScript">
// Courtesy of SimplytheBest.net - http://simplythebest.net/scripts/
<!-- Begin

var expDays = 1; // number of days the cookie should last
var page = "signup.htm";
var windowprops = "width=300,height=200,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) {
SetCookie('count','1')
return 1
}
else {
var newcount = parseInt(count) + 1;
DeleteCookie('count')
SetCookie('count',newcount,exp)
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) {
count=1;
SetCookie('count', count, exp);
window.open(page, "", windowprops);
}
else {
count++;
SetCookie('count', count, exp);
}
}
// End -->
</script>


<body onLoad= "checkCount()" bgcolor="#99CC99" link="#003565" vlink="#003565" alink="#003565" leftmargin="0" topmargin="0">
 Yes, it is ok.  Kwaoc,you can use it.