Basically this code is added to an include file . User comes to site, browses to third page, on the way cookie is set 1st page value=1, second page value=2, third page value=3 launch pop up.
All is good works on mac and pc, on mac however once it reaches the value of 3 it launches the pop on all pages after words cause value always =3. Pc it does not show the pop up again unless the cookies are cleared which is ok.
I guess though my question is how can i set this to where once it = 3 on a mac it doesnt show again unless cookies are cleared?
----------------------------------------
All is good works on mac and pc, on mac however once it reaches the value of 3 it launches the pop on all pages after words cause value always =3. Pc it does not show the pop up again unless the cookies are cleared which is ok.
I guess though my question is how can i set this to where once it = 3 on a mac it doesnt show again unless cookies are cleared?
Code:
function setPageNumber(){
//Insert current page number
var currentPageCount = getCookie("pageNumber");
if (getCookie("pageNumber")==null){//if there is no cookie
document.cookie="pageNumber=1";//create the cookie
}
else{
incrementPageNumber(currentPageCount);//add 1 to the "pageNumber" value
}
}
function incrementPageNumber(i){
if (i != 2) { //if the page number is not equal to 2
i++;//add one to the page number
document.cookie="pageNumber="+i;//and write it to the cookie
}
else{
//open the pop up window
if (getCookie("windowOpened") != "true"){ //if the window hasn't already been opened
window.open('popup.html','newwin','width=350,height=255,left=0,top=0,toolbar=no,location=no,scrollbars=no,status=no,resizable=no,fullscreen=no');newwindow.focus();void(0);
document.cookie="windowOpened = true";
}
}
}
//function to read cookie
function getCookie(Name) {
var search = Name + "="
if (document.cookie.length > 0) { // if there are any cookies
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
return unescape(document.cookie.substring(offset, end))
}
}
}
window.onload = setPageNumber;
----------------------------------------