I don't know how good an idea it is to use an unrequested popup, and I suspect a lot of people are blocking it anyway, but you could use a cookie to keep track of whether or not they've seen the page already. I found these cookie functions so long ago that I don't remember where to credit them, but I've used them successfully a couple of times:
<html>
<head>
<title>Untitled</title>
<script type="text/javascript">
<!--
function setCookie(name, value, expires, path, domain, secure) {
var curCookie = name + "=" + escape(value) +
((expires) ? "; expires=" + expires.toGMTString() : "") +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
((secure) ? "; secure" : "");
document.cookie = curCookie;
}
function getCookie(name) {
var dc = document.cookie;
var prefix = name + "=";
var begin = dc.indexOf("; " + prefix);
if (begin == -1) {
begin = dc.indexOf(prefix);
if (begin != 0) return null;
} else
begin += 2;
var end = document.cookie.indexOf(";", begin);
if (end == -1)
end = dc.length;
return unescape(dc.substring(begin + prefix.length, end));
}
function pop()
{
theUrl = "http://www.yahoo.com";
window.open(theUrl,"theWindow","width=400,height=400,menubar=yes,toolbar=yes")
}
var seen = getCookie("seen");
if (!seen) {
var now = new Date();
now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
setCookie("seen", 1, now);
pop();
}
//-->
</script>
</head>
<body>
blah
</body>
</html>
- <html>
- <head>
- <title>Untitled</title>
- <script type="text/javascript">
- <!--
- function setCookie(name, value, expires, path, domain, secure) {
- var curCookie = name + "=" + escape(value) +
- ((expires) ? "; expires=" + expires.toGMTString() : "") +
- ((path) ? "; path=" + path : "") +
- ((domain) ? "; domain=" + domain : "") +
- ((secure) ? "; secure" : "");
- document.cookie = curCookie;
- }
- function getCookie(name) {
- var dc = document.cookie;
- var prefix = name + "=";
- var begin = dc.indexOf("; " + prefix);
- if (begin == -1) {
- begin = dc.indexOf(prefix);
- if (begin != 0) return null;
- } else
- begin += 2;
- var end = document.cookie.indexOf(";", begin);
- if (end == -1)
- end = dc.length;
- return unescape(dc.substring(begin + prefix.length, end));
- }
- function pop()
- {
- theUrl = "http://www.yahoo.com";
- window.open(theUrl,"theWindow","width=400,height=400,menubar=yes,toolbar=yes")
- }
- var seen = getCookie("seen");
- if (!seen) {
- var now = new Date();
- now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
- setCookie("seen", 1, now);
- pop();
- }
- //-->
- </script>
- </head>
- <body>
- blah
- </body>
- </html>
That cookie is set to expire in one year (365 * 24 * 60 * 60 * 1000), but you can change the expiration date to whatever you want. For example, you could change the 365 to 1 and it would expire in one day. Keep in mind that some people set their browsers so that cookies expire after 90 days or after the session ends and some folks block cookies entirely, so there's no absolute guarantee that it will work for everyone. If cookies are blocked it won't work at all of course, if they are set to expire after the session ends then the person will see the popup the next time they visit, or after 90 days or however long they've set the cookies to expire.
Free Programming Resources