...

View Full Version : Help with pop up window script



jilly23
07-07-2003, 06:06 PM
I am using the following script on my site to load a popup ad.. However I want it to open only once...Not every visit to the page.. How do I configure the script to do this?

Here it is -

<script>

//Popup Window Script
//By JavaScript Kit (http://javascriptkit.com)
//JavaScript tutorials and over 400+ free scripts

function openpopup(){
var popurl="ccad.html"
winpops=window.open(popurl,"","width=531,height=370,")
}

function get_cookie(Name) {
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) { // if cookie exists
offset += search.length
// set index of beginning of value
end = document.cookie.indexOf(";", offset);
// set index of end of cookie value
if (end == -1)
end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}

function loadornot(){
if (get_cookie('poppedup')==''){
openpopup()
document.cookie="poppedup=yes"
}
}

loadornot()
</script>

requestcode
07-07-2003, 06:13 PM
That should work if they don't close their browser down, open it back up and go to the page. The script sets a cookie so that is won't open up again within the same browser session. Is that not working?

jilly23
07-07-2003, 07:15 PM
Yes it is working for the session but I do not want a session cookie I want it show only once ever and then not again...

requestcode
07-07-2003, 07:57 PM
You will need to add an expiration date to the cookie. try this link for an explanation on how to do it:
http://devedge.netscape.com/library/manuals/2000/javascript/1.3/reference/cookies.html

It is old, but still relavent.

jilly23
07-07-2003, 08:16 PM
Thanks for the information - the one page ont he site keeps crashing my browser...

How would I configure the code that I have? Or would I have to use a totally different script?

Thanks for all your help!

zoobie
07-08-2003, 02:47 AM
I wouldn't use pop-ups...Everybody is turning them off. :D



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum