javascript操作cookie_获取与修改代码

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

javascript操作cookie_获取与修改代码

  2020-05-12 我要评论
复制代码 代码如下:

function $Cookie(){
var a=arguments.callee;
var b=a._cached;
if(a._cached){return a._cached}
if(!(this instanceof a)){return new a}
if(typeof a._cached=="undefined"){a._cached=this}
}
$Cookie.prototype.get=function(e){
var a=document.cookie.split(/\s*;\s*/);
var d=new RegExp("^(\\s*"+e+"\\s*=)");
for(var b=0;b<a.length;b++){
if(d.test(a[b])){return unescape(a[b].substr(RegExp.$1.length))}
}
return null
};
$Cookie.prototype.set=function(e,f,d,a){
var b="";
if(typeof d=="number"){b=";expires="+(new Date((new Date()).getTime()+d*1000*60*60*24)).toGMTString()}
if(typeof a=="undefined"){a=""}
document.cookie=e+"="+escape(f)+b+"; path=/"+(a?"; domain="+a:"");
return this
};
$Cookie.prototype.remove=function(a){
if(this.get(a)!=null){this.set(a,"",-1)}
return this
};

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们