cache 存储常用方法
/**
* [设置cookie]
* @param {[string]} key [键]
* @param {[string]} value [值]
* @param {[number]} t [过期时间(天)]
*/
function setCookie(key, value, t) {
var oDate = new Date();
oDate.setDate(oDate.getDate() + t);
document.cookie = key + "=" + value + ";expires=" + oDate.toGMTString();
}
/**
* [读取cookie]
* @param {[string]} key [键]
* @return {[type]} [description]
*/
function getCookie(key) {
var arr1 = document.cookie.split("; ");
for (var i = 0; i < arr1.length; i++) {
var arr2 = arr1[i].split("=");
if (arr2[0] == key) {
return decodeURI(arr2[1]);
}
}
}
/**
* [删除cookie]
* @param {[string]} key [键]
* @return {[type]} [description]
*/
function removeCookie(key) {
myJsPag.setCookie(key, "", -1);
}