Java开发网 |
注册 |
登录 |
帮助 |
搜索 |
排行榜 |
发帖统计
|
您没有登录 |
» Java开发网 » AJAX讨论区
打印话题 寄给朋友 订阅主题 |
作者 | Javascript操作cookie完美实现 |
Happy漫步者
发贴: 28 |
于 2009-09-05 20:31
function setCookie(name, value, expires, path, domain, secure) {document.cookie = name + "=" + escape(value) + ((expires) ? "; expires=" + expires : "") + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : ""); } function delCookie(name) {var exp = new Date(); exp.setTime (exp.getTime() - 1); var cval = getCookie (name); document.cookie = name + "=" + cval + "; expires="+ exp.toGMTString(); } function getCookie(name){ var cookies = document.cookie.split( ';' ); var cookie = ''; for(var i=0; i<cookies.length; i++){ cookie = cookies[i].split('='); if(cookie[0].replace(/^s+|s+$/g, '') == name) { return (cookie.length <= 1) ? "" : unescape(cookie[1].replace(/^s+|s+$/g, '')); } } return null; } function getExpDate(days, hours, minutes) {var expDate = new Date(); if(typeof(days) == "number" && typeof(hours) == "number" && typeof(hours) == "number"){ expDate.setDate(expDate.getDate() + parseInt(days)); expDate.setHours(expDate.getHours() + parseInt(hours)); expDate.setMinutes(expDate.getMinutes() + parseInt(minutes)); return expDate.toGMTString();} return null;} ----- From:http://www.txdnet.cn/essay/view.jsp?tid=1252053157626&cid=2&f=_cjsdn_js_2 Happy漫步者花园 当我们失去的时候,才知道自己曾经拥有过 |
已读帖子 新的帖子 被删除的帖子 |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |