jQuery.cookie源代码
jQuery.cookie=function(name,value,options){
if(typeofvalue!='undefined'){//nameandvaluegiven,setcookie
options=options||{};
if(value===null){
value='';
options.expires=-1;
}
varexpires='';
if(options.expires&&(typeofoptions.expires=='number'||options.expires.toUTCString)){
vardate;
if(typeofoptions.expires=='number'){
date=newDate();
date.setTime(date.getTime()+(options.expires*24*60*60*1000));
}else{
date=options.expires;
}
expires=';expires='+date.toUTCString();//useexpiresattribute,max-ageisnotsupportedbyIE
}
varpath=options.path?';path='+options.path:'';
vardomain=options.domain?';domain='+options.domain:'';
varsecure=options.secure?';secure':'';
document.cookie=[name,'=',encodeURIComponent(value),expires,path,domain,secure].join('');
}else{//onlynamegiven,getcookie
varcookieValue=null;
if(document.cookie&&document.cookie!=''){
varcookies=document.cookie.split(';');
for(vari=0;i<cookies.length;i++){
varcookie=jQuery.trim(cookies[i]);
//Doesthiscookiestringbeginwiththenamewewant?
if(cookie.substring(0,name.length+1)==(name+'=')){
cookieValue=decodeURIComponent(cookie.substring(name.length+1));
break;
}
}
}
returncookieValue;
}
};
优质内容筛选与推荐>>
1、LightOJ 1049 - One Way Roads2、深入销售单-定义短信事件触发3、MD5加密(JAVA&JS)4、网络五子棋JAVA代码5、左侧导航栏显示隐藏toggle使用
长按二维码向我转账
受苹果公司新规定影响,微信 iOS 版的赞赏功能被关闭,可通过二维码转账支持公众号。