zoukankan
html css js c++ java
JavaScript操作Cookie 插件
JavaScript操作Cookie 插件,标注已经很清楚了,请看具体代码:
//Cookie类 function Cookie(){ Cookie.prototype=new Object();//继承自Object this.constructor=Cookie; //重写toString函数,生成为document.cookie形式的字符串 Cookie.prototype.toString=function(){ var data=[];//存放cookie子键 var _cookie=[];//存放cookie键值对 for(var prop in this){ switch(true){ case prop=="name": _cookie[0]=prop; continue; case prop=="expires": _cookie[1]=prop+"="+this[prop]; continue; case prop=="path": _cookie[2]=prop+"="+this[prop]; continue; case prop=="secure": _cookie[3]=prop+"="+this[prop]; continue; case prop=="domain": _cookie[4]=prop+"="+this[prop]; continue; } data[data.length]=prop+":"+escape(this[prop]); } _cookie[0]+="="+data.join("&"); return _cookie.join(";"); }; return this;//返回cookie对象 } //将字符串格式化为cookie, 静态函数 Cookie.format=function(str){ var cookie=new Cookie(); var start=str.indexOf("="); cookie.name=str.substring(0,start); var value=str.substring(start+1); value=value.split('&'); for ( var v in value ){ v=v.split(':'); this[v[0]]=unescape(v[1]); } return cookie; }; //获取当前所有cookie, 静态对象 Cookie.cookies=(function(){ var cookie=document.cookie; var obj; cookie=cookie.split(';'); for (var c in cookie){ c=Cookie.format(c); obj[c.name]=c; } return obj; })(); //添加cookie, 静态函数 Cookie.Add=function(cookie){ if(cookie instanceof Cookie){ document.cookie=cookie.toString(); } //else console.log("参数错误"); } //删除cookie, 静态函数 Cookie.Remove=function(cookie){ if(cookie instanceof Cookie){ var time=new Data(); time.setFullYear(time.getFullYear()-10); cookie.expires=time.toGMTString(); document.cookie=cookie.toString(); } }
作者:
灵雨飘零
出处:
http://www.cnblogs.com/kingboy2008/
本文版权归作者和博客园、CSDN共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。该文章也同时发布在我的独立博客中-
博客园—灵雨飘零
和
CSDN—灵雨飘零
。
查看全文
相关阅读:
The Problem Came Up when we upgrade from KingDee K3 to SAP R3(FI module)
小代码 OpenFileDialog() Windows下Upload & rewrite 文件
[Note]CodeSmith 4.0 Lesson One
正则表达式 运算 常见
SAP function overview & instruction
CodeSmith NetTier 保存主从表实例,当然,至于3级关联的问题还是类似做法,依靠Relationship做级联更新
CodeSmith NetTier模板生成的代码框架用法 (转)
[Notes] Demo The practice about how to using SAP XI components to build up the mapping bridge cross the application layer
6260/7610/6670/3230 蓝牙 共享PC 宽带 无须代理
[ALE in SAP]BAPI Introduction
原文地址:https://www.cnblogs.com/kingboy2008/p/2124740.html
最新文章
查看哪些程序打开哪些端口 dos命令
qq2009及以上版本的系统表情
3G挂Q技术笔记(登陆QQ原来这么简单)
为使用Sixxpack加壳的.net程序脱壳
QQ2009 sp6出错后的提示信息协议分析
MSN不能保存聊天记录,自动保留对话的历史记录选项为灰色[解决办法]
[ABAP Part TWO] Program Development Phase 2 Your Coding Style Define The Quality
[ABAP Part Three] Program Development Phase 3 Call Query Form Introduction
富士 施乐 Biz Services Outsource Introduction
[Note] CodeSmith Lesson Two [转自 努力学习的熊 ] 感谢原作者
热门文章
CodeSmith Nettier调用Transaction事务Sample
常见正则表达式运算 Regex 替换字符
ERP 起源.... 早在1000多年前我国就早已开发了成熟的ERP理论,并且在全国各地广泛使用
SAP MRP Basic Draft(1)
猎头人生, FOR IT Candidate 转CSDN
SAP R/3 Material Master Record <2>
CodeSmith NetTier 对于主从表级联显示的SAMPLE ObjectDataSource
[ABAP Part One] Program Development Phase 1 Basic Sturcture & Obj Overview
SAP PLM Basic <1> Draft
国内主流IT公司Field Sales销售薪资 来自著名猎头公司内部信息 给IT的朋友们知道个行情 天涯
Copyright © 2011-2022 走看看