最新下载
热门教程
- 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();}
相关文章
- 《无限暖暖》天星之羽获得位置介绍 12-20
- 《流放之路2》重铸台解锁方法介绍 12-20
- 《无限暖暖》瞄准那个亮亮的成就怎么做 12-20
- 《无限暖暖》魔气怪终结者完成方法 12-20
- 《无限暖暖》曙光毛团获得位置介绍 12-20
- 《无限暖暖》日光果获得位置介绍 12-20