-
Redirect code not working
I've got a situation where I need my site to drop a cookie so that each time the user returns they're redirected to one of five new pages, in order. I've gotten a code which works everywhere apart from Safari, and I can't see why! I"ll give people a look at it, maybe someone can let me know what the problem is with Safari. </head> <body onload = "readCookie(name)"> <script type = "text/javascript"> var name = "mypage"; var value = 0; var days = 365; // days before cookie expires function createCookie(name,value,days) { 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=/"; // available throughout the directory var newpage = "flash" + value + ".html"; window.location = newpage; //redirect to the new page } function readCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for(var i = 0;i < ca.length; i++) { var c = ca[i]; while (c.charAt(0)==' ') value = c.substring(1,c.length); if (c.indexOf(nameEQ) == 0) value = c.substring(nameEQ.length,c.length); } value ++; if (value > 5) { value = 1 } // redirect pages are yourpage + 1,2,3,4,5 createCookie(name,value,days); return null; } </script> <div id="container"> <div id="header"> <h1>Target </h1> <div id="bordersplash"> </div> </div> </body> </html> I'd be so grateful for any tips any of you Safari guys might have! Cheers!
-
Does nyone have the code for this?
Would you happen to have the code for this? This is some code I've gotten elsewhere and it works perfectly on Opera and Firefox but while it loads on Safari it doesn't produce the same cookie trick. Might anyone know why this is? Eternal gratitude etc... I'm so very close! <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Target Media</title> <meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type"/> </style> <script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script> </head> <body onload = "readCookie(name)"> <script type = "text/javascript"> var name = "mypage"; var value = 0; var days = 365; // days before cookie expires function createCookie(name,value,days) { 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=/"; // available throughout the directory var newpage = "flash" + value + ".html"; window.location = newpage; //redirect to the new page } function readCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for(var i = 0;i < ca.length; i++) { var c = ca[i]; while (c.charAt(0)==' ') value = c.substring(1,c.length); if (c.indexOf(nameEQ) == 0) value = c.substring(nameEQ.length,c.length); } value ++; if (value > 5) { value = 1 } // redirect pages are yourpage + 1,2,3,4,5 createCookie(name,value,days); return null; } </script> <div id="container"> <div id="header"> <h1>Target </h1> <div id="bordersplash"> </div> </div> </body> </html> Cheers for any help!
-
Does nyone have the code for this?
It's a site where the client wants the user to see a new image each time that they go to the site. This can't be random as it migt result in the same image twice. Cookies seem to be the best way. Have you any idea how to do this? Cheers!
-
Does nyone have the code for this?
hey, I'm looking for some basic enough code, but obviously beyond me at this stage. It seems it could be a javascript thing. I need an index page to load a cookie with the user so that each time they load the site they are brought to a different index page. There are five index pages and must load in a particular sequence, ie not randomly. If anyone has any examples of this working or any code it would be greatly appreciated! Many thanks!
-
Hi From Alan in London
Hi all, by way of introduction, I've just joined up here for the first time and am looking forward to hopefully helping some people out and others helping me out of sticky situations too! Cheers!