标签:remove strong document block val 删除cookie 查找 expires var
//获取cookie
function getCookie(key,value){
var c = document.cookie;
var str = key + ‘=‘ + value;
var re = new RegExp(‘(^|\\s)‘+str+‘;?($|\\s)‘);
return re.test(c);
}
//设置cookie
function setCookie(key,val,time){
time = time?time:0;
var data = new Date();
data.setDate(data.getDate()+time);
document.cookie = key+‘=‘+val+‘;expires=‘+(time?data:0);
}
//删除cookie
function removeCookie(key,value){
setCookie(key,value,-1);
}
标签:remove strong document block val 删除cookie 查找 expires var
原文地址:http://www.cnblogs.com/week-1/p/6576324.html