Operation cookie. Determine the browser system version, determine the safir browser to store data, cookiesafir

Source: Internet
Author: User
Tags sessionstorage

Operation cookie. Determine the browser system version, determine the safir browser to store data, cookiesafir

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. */), // whether it is a Mobile terminal
Ios :!! U. match (/\ (I [^;] +; (U ;)? CPU. + Mac OS X/), // ios Terminal
Android: u. indexOf ('android')>-1, // Android Terminal
IPhone: u. indexOf ('iphone ')>-1, // whether the iPhone is
IPad: u. indexOf ('ipad ')>-1, // whether iPad
WebKit: u. indexOf ('applewebkit')>-1, // Apple, Google Kernel
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;
}
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.