一个js cookie操作类
来源:互联网 发布:ag游戏平台源码 编辑:程序博客网 时间:2024/05/18 02:17
用例:
cookie = new cookie;
cookie.set('text1','123');
cookie.set('text2','321',3600*24);
text2 = cookie.get('text2');
cookie.del('text2');
cookie.setlifetime(3600*24*2);
cookie.set('text3','456');
alert(cookie.getall());
cookie.js——
var cookie = cookie || function(){
cookies = document.cookie.split('; ');for (i in cookies){
cookie = cookies[i].split('=');
this.cookies[cookie[0]] = cookie[1];
}
this.date = new Date();//日期初始化
}
cookie.prototype = {
cookies:[],//cookie值存储器
lifetime:null,//生命周期存储器,单位毫秒
date:null,//日期存储器
setlifetime:function(lifetime){
if (lifetime = parseInt(lifetime)){
this.lifetime = lifetime;
}
return this;
},
get:function(name){
if (this.cookies[name]){
return this.cookies[name];
}else{
return false;
}
},
getall:function(){
return document.cookie;
},
set:function(name,value,lifetime){
cookieText = name+'='+value+';';
lifetime = lifetime || this.lifetime;
if (lifetime = parseInt(lifetime)){
this.date.setTime(this.date.getTime()+lifetime*1000);
cookieText += 'expires='+this.date.toGMTString();
}
document.cookie = cookieText;
return this;
},
del:function(name){
if (this.cookies[name]){
this.date.setTime(this.date.getTime()-10000);
document.cookie = name+'=;expires='+this.date.toGMTString();
}
return this;
}
};
- 一个js cookie操作类
- 一个用JS操作Cookie的类
- JS 操作Cookie 类
- js操作cookie的类
- js 操作cookie的类
- cookie.js js操作cookie
- jquery.cookie.js操作cookie-
- jquery.cookie.js操作Cookie
- jquery.cookie.js操作Cookie
- JS脚本操作COOKIE
- JS 对 cookie 操作
- js cookie 的操作
- JS操作Cookie详解
- JS操作Cookie详解
- js 操作cookie详解
- JS进行Cookie操作
- JS操作COOKIE
- js cookie 的操作
- 61 确保简单问题有简单的解
- ListView 滚动翻页/滚动加载
- tomcat文件夹与文件解析
- Java继承中属性、方法和对象的关系
- Google的几个地理位置相关的API
- 一个js cookie操作类
- ibatis中SqlMapConfig的oracle数据库配置
- glib源码学习
- for循环的基础面试,确定能答对??
- 水利行业相关资料
- Securing Your Connection String in Windows Azure: Part 1
- cursor
- atoi函数实现
- 2012C++程序设计实验报告【9.2】