最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
javascript cookie类(删除cookie,获取,设置cookie值
时间:2022-11-14 22:02:59 编辑:袖梨 来源:一聚教程网
function issetcookie(){//网页特效检查cookie的函数
bannercenter = 网页特效getcookie('bannercenter');
if (bannercenter!=null && bannercenter!=""){
return true;
} else {
setcookie('bannercenter',1,3600*24);
}
}
//===============================================
function jsgetcookie(name){//获得cookie的原始值
var cookstringarray = window.document.cookie.split("; ");
for(var i=0; ivar cookieinfo = cookstringarray[i].split("=");
if(name == cookieinfo[0]) {
return unescape(cookieinfo[1]);
}
}
return null;
}function setcookie(name, value){//设定cookie值
var expdate = new date();
var argv = setcookie.arguments;
var argc = setcookie.arguments.length;
var expires = (argc > 2) ? argv[2] : null;
var path = (argc > 3) ? argv[3] : null;
var domain = (argc > 4) ? argv[4] : null;
var secure = (argc > 5) ? argv[5] : false;
if(expires!=null) expdate.settime(expdate.gettime() + ( expires * 1000 ));
document.cookie = name + "=" + escape (value) +((expires == null) ? "" : ("; expires="+ expdate.togmtstring()))
+((path == null) ? "" : ("; path=" + path)) +((domain == null) ? "" : ("; domain=" + domain))
+((secure == true) ? "; secure" : "");
}
//=============================================
function delcookie(name){//删除cookie
var exp = new date();
exp.settime (exp.gettime() - 1);
var cval = getcookie (name);
document.cookie = name + "=" + cval + "; expires="+ exp.togmtstring();}
相关文章
- 人们熟悉的寄居蟹属于以下哪种分类 神奇海洋11月21日答案 11-21
- 第五人格11.22共研服有什么更新 11月22日共研服更新内容介绍 11-21
- 原神恰斯卡怎么培养 11-21
- 无期迷途四星装束是谁 11-21
- 王者荣耀帝丹高中校服怎么获得 11-21
- 光遇姆明季后续版本怎么玩 11-21