ReadCookie_sns = function(){ ReadCookie("myname"); }
出错,提示:Unexpected token u in JSON at position 0
改为:
ReadCookie_sns = function(){ return ReadCookie("myname"); }
好了。 加了return, 就好了。请问为什么?
-----------------下面是ReadCookie方法。
ReadCookie = function(cookieName) {
var theCookie = "" + document.cookie;
var ind = theCookie.indexOf(cookieName);
if (ind == -1 || cookieName == "") return "";
var ind1 = theCookie.indexOf(';', ind);
if (ind1 == -1) ind1 = theCookie.length;
/*读取Cookie值*/
return unescape(theCookie.substring(ind + cookieName.length + 1, ind1));
}
相关分类