I’m trying to make a redirection if a cookie exist, it’s working on Chrome and Firefox, but it’s not on Opera, IE and Safari.
function listenCookieChange() {
var intervalHolder = setInterval(function() {
if(getCookie('foo')){
clearInterval(intervalHolder);
window.location.href = 'http://XXXXXXXXXXXXXX/inscription2.php';
}
}, 100);
}
listenCookieChange();
The cookies are set on the browser so the problem is not coming from that part.
Thanks in advance
Edit: Here’s the code for the getCookie
function getCookie(c_name)
{
var i,x,y,ARRcookies=document.cookie.split(";");
for (i=0;i<ARRcookies.length;i++)
{
x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
x=x.replace(/^\s+|\s+$/g,"");
if (x==c_name)
{
return unescape(y);
}
}
}
Can not find any fault. Have tested your script on IE7-IE9 and Opera 10-11.