I'm trying to read a cookie so that if the value of the cookie != neverAgain then open a pop up survey. If it the value of the cookie == neverAgain then do not show the pop up survey.
I create the cookie with an onClick in the pop up survey so that once a user has completed the survey they should not see it again.
Cookie creation code:
function newCookie(name,value) {
var days = 99999;
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString(); }
else
var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
window.close();
}
I use an onLoad in the html body tag to check the value of the cookie. Code that looks at the cookie:
function readCookie(name) {
var nameSG = name + "=";
var ca = document.cookie.split(';');
for(var i=0; i<ca.length; i++) {
var c = ca;
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameSG) == 0) return c.substring(nameSG.length,c.length); }
return null; }
function launchSurvey() {
var val = readCookie("SurveyForm");
if (val == "neverAgain") {
this.window.location = "mypage.html";
}
if (val != "neverAgain") {
window.open("survey_form.html","itportalsurvey","width=410,height=520");
}
}
Is the trouble in my if Statements.
Any help would be appreciated.
Thanks
I create the cookie with an onClick in the pop up survey so that once a user has completed the survey they should not see it again.
Cookie creation code:
function newCookie(name,value) {
var days = 99999;
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString(); }
else
var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
window.close();
}
I use an onLoad in the html body tag to check the value of the cookie. Code that looks at the cookie:
function readCookie(name) {
var nameSG = name + "=";
var ca = document.cookie.split(';');
for(var i=0; i<ca.length; i++) {
var c = ca;
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameSG) == 0) return c.substring(nameSG.length,c.length); }
return null; }
function launchSurvey() {
var val = readCookie("SurveyForm");
if (val == "neverAgain") {
this.window.location = "mypage.html";
}
if (val != "neverAgain") {
window.open("survey_form.html","itportalsurvey","width=410,height=520");
}
}
Is the trouble in my if Statements.
Any help would be appreciated.
Thanks