PDA

View Full Version : Pop up window script using cookie


Dean
09-04-2002, 11:01 AM
Hi there

Can anybody help me i have found a script that pops up a popup only once each time someone visits the site.

Is there any way to change this so that the cookie for this pop is not a session cookie but that the cookie last last for 7 days?:confused:

so if a user visits my site 3 or 4 times a day they do not get hit with the same pop ups every time but only once and then not see them for seven days.

this way any popup will get seen but my regualar visitors will not get annoyed by the popup. :mad:

this is the script i have found:

<script>

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

function openpopup(){
var popurl="thankyou.htm"
winpops=window.open(popurl,"","width=400,height=338,")
}

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>

So if you know how I can change this so the cookie lasts for seven days then please let me know as I am just starting to get to grips with javascripts and any help is gratefully accepted.:thumbsup: