你的位置:首页 > 网页设计

[网页设计]操作cookie.判断浏览器系统版本,判断safir浏览器存储数据


var Safir = {
GetLocalStorage: function (key) {
var storage = window.localStorage;
if (storage.getItem(key)) {
var l = storage.getItem(key);
return l;
} else {
return "0";
}
},
DeleteSessionStorage: function (key) {
var f = "0";
storage = window.sessionStorage;
try {
storage.removeItem(key);
f = "1";
} catch (error) {
f = "2";
}
return f;
},
DeleteLocalStorage: function (key) {
var f = "0";
storage = window.localStorage;
try {
storage.removeItem(key);
f = "1";
} catch (error) {
f = "2";
}
return f;
},
IsSessionStorage: function (key) {
var f = false;
storage = window.sessionStorage;
try {
storage.setItem(key, key);
storage.removeItem(key);
f = true;
} catch (error) {
f = false;
}
return f;
},
AddLocalStorage: function (key) {
var f = "0";
storage = window.localStorage;
try {
storage.removeItem(key);
storage.setItem(key, key);
f = "1";
} catch (error) {
f = "2";
}
return f;
},
AddLocalStorage: function (key, value) {
var f = "0";
storage = window.localStorage;
try {
storage.removeItem(key);
storage.setItem(key, value);
f = value;
} catch (error) {
f = "2";
}
return f;
},
AddSessionStorage: function (key) {
var f = "0";
storage = window.sessionStorage;
try {
storage.removeItem(key);
storage.setItem(key, key);
f = "1";
} catch (error) {
f = "2";
}
return f;
},
AddSessionStorage: function (key, value) {
var f = "0";
storage = window.sessionStorage;
try {
storage.removeItem(key);
storage.setItem(key, value);
f = value;
} catch (error) {
f = "2";
}
return f;
}
}
var Phone = {
Versions: function () {
var u = navigator.userAgent, app = navigator.appVersion;
return {
mobile: !!u.match(/AppleWebKit.*Mobile.*/), //是否为移动终端
ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端
android: u.indexOf('Android') > -1, //android终端
iPhone: u.indexOf('iPhone') > -1, //是否为iPhone
iPad: u.indexOf('iPad') > -1, //是否iPad
webKit: u.indexOf('AppleWebKit') > -1, //苹果、谷歌内核
QQBrowser: u.indexOf('QQBrowser') > -1,
QQ: u.indexOf('QQ') > -1,
wechat: function () {
if (u.match(/MicroMessenger/i) == 'MicroMessenger')
{ return true; }
else { return false; }
} ()
};
} ()
}
var cookie = {
addCookie: function (key, value, time) {
$.cookie(key, value, { expires: 1, path: '/', domain: '.neihanhongbao.com', secure: false, raw: false });
},
getCookie: function (key) {
return $.cookie(key);
},
delCookie: function (key) {
$.cookie(key, '', { expires: -1 });
},
checkCookie: function (key) {
var f = "0";
if ($.cookie(key) == undefined || $.cookie(key) == "") {
f = "1";
}
else {
f = "2";
}
return f;
}
}