我遇到了cookie问题。这是检索cookie的代码(并对其执行了一些操作):
var crtg_cookiename = "cto_zodiak";
var crtg_varname = "crtg_content";
function crtg_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);
}
}
return '';
}
var crtg_content = crtg_getCookie(crtg_cookiename);
我在chrome和firefox控制台中尝试这个代码:在firefox中我可以检索cookie并处理它但是在chrome document.cookie中没有返回任何内容。任何人都知道原因吗?
提前致谢