js获取手机端cookie使loading页面只在第一次打开网页的时候出现 当有cookie之后怎么刷新也不会再出现

2025-01-01 05:01:34
推荐回答(1个)
回答1:

我之前写的方法,给你参考:
另外,刷新不会在出现的原因,可能是因为在 localhost ,你要有网域或是 ip , Cookie 才会记录的。不懂可以私信问我详细
function setCookie(cname, cvalue, exdays) {
var d = new Date();
d.setTime(d.getTime() + (exdays*24*60*60*1000));
var expires = "expires="+d.toUTCString();
document.cookie = cname + "=" + cvalue + "; " + expires;
}
function getCookie(cname) {
var name = cname + "=";
var ca = document.cookie.split(';');
for(var i=0; i var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1);
if (c.indexOf(name) == 0) return c.substring(name.length, c.length);
}
return "";
}