最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

js文件Cookie存取值示例代碼

 更新時(shí)間:2014年02月20日 16:40:37   作者:  
這篇文章主要介紹了js文件Cookie存取值的使用,需要的朋友可以參考下
復(fù)制代碼 代碼如下:

/*
Cookie工具
使用方法:
//存值
var value = "7天";
tools.cookie("day",value, {expires:7}); //將字符串:"7天" 以 "day"這個(gè)key保存到cookie中5天
//取值
var v = tools.cookie("day"); //用 "day" 這個(gè)key從cookie取出值
*/
tools.cookie = function(name, value, options) {
if (typeof value != 'undefined') { // name and value given, set cookie
options = options || {};
if (value === null) {
value = '';
options.expires = -1;
}
var expires = '';
if (options.expires
&& (typeof options.expires == 'number' || options.expires.toGMTString)) {
var date;
if (typeof options.expires == 'number') {
date = new Date();
date.setTime(date.getTime()
+ (options.expires * 24 * 60 * 60 * 1000));
} else {
date = options.expires;
}
expires = '; expires=' + date.toGMTString(); // use expires
// attribute,
// max-age is not
// supported by IE
}
var path = options.path ? '; path=' + options.path : '';
var domain = options.domain ? '; domain=' + options.domain : '';
var secure = options.secure ? '; secure' : '';
document.cookie = [ name, '=', encodeURIComponent(value), expires,
path, domain, secure ].join('');
} else { // only name given, get cookie
var cookieValue = null;
if (document.cookie && document.cookie != '') {
var cookies = document.cookie.split(';');
for ( var i = 0; i < cookies.length; i++) {
var cookie = jQuery.trim(cookies[i]);
// Does this cookie string begin with the name we want?
if (cookie.substring(0, name.length + 1) == (name + '=')) {
cookieValue = decodeURIComponent(cookie
.substring(name.length + 1));
break;
}
}
}
return cookieValue;
}
};

相關(guān)文章

最新評(píng)論

安福县| 简阳市| 秦安县| 咸阳市| 乳山市| 阿克| 平阳县| 新民市| 永新县| 封丘县| 云南省| 和静县| 阿勒泰市| 兴安盟| 新民市| 如皋市| 崇明县| 清流县| 太仓市| 同江市| 灯塔市| 霍山县| 呼伦贝尔市| 昂仁县| 白玉县| 普宁市| 上高县| 阜平县| 定结县| 竹山县| 分宜县| 沿河| 凤庆县| 望谟县| 宁波市| 九龙城区| 仲巴县| 德州市| 凉城县| 韶关市| 延边|