最新国产好看的视频,伊人天堂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)論

河池市| 合川市| 余干县| 嘉义县| 横山县| 白水县| 长顺县| 武城县| 娄烦县| 聊城市| 伊通| 阜南县| 徐汇区| 郁南县| 阿巴嘎旗| 博湖县| 常山县| 宣恩县| 柯坪县| 深州市| 都昌县| 蓝山县| 石林| 上饶市| 兴文县| 凤翔县| 正定县| 德州市| 阳谷县| 紫金县| 新郑市| 临湘市| 治县。| 高要市| 峨眉山市| 威宁| 余姚市| 林口县| 安新县| 耿马| 镇安县|