1. Check the features of the desktop browser.
$. Checkdetect = function (){
VaR detect = {
IE:/MSIE \ s * \ D + \. \ D/GI,
Chrome:/chrome \/[\ W \.] + (\ s )? /GI,
Firefox:/Firefox \/[\ W \.] + (\ s )? /GI,
};
VaR UA = navigator. useragent. tolowercase (),
Info = {},
Match = [];
For (I in detect ){
Match = UA. Match (detect [I]);
If (MATCH ){
Info. browser = I;
Info. Version = match. Join (""). Match (/[0-9] +/g). Join (".");
}
}
Return Info;
}
Check mobile browser attributes:
Checkdetect = function (){
VaR detect = {
WebKit:/(applewebkit) [\/] ([\ W.] + )/,
IPad:/(IPAD). + \ SOS \ s ([\ D + \ _] +)/I,
Windows:/(Windows \ D *) \ snt \ s ([\ D ++ \.] +)/I,
IPhone:/(iPhone) \ SOS \ s ([\ D + \ _] +)/I,
IPod:/(iPod). + \ SOS \ s ([\ D + \ _] +)/I,
Android:/(Android) \ s ([\ D ++ \.] +)/I
};
VaR UA = Window. Navigator. useragent,
Browser = detect.webkit.exe C (UA ),
IOS = // \ (iPhone | iPad | iPod)/I. Test (UA ),
// ["IPhone OS 5_1", "iPhone", "5_1"]
TMP = [],
N = {},
Match = [];
For (I in detect ){
Match = detectpolici2.16.exe C (UA );
If (MATCH ){
TMP = detectpolicicmd.exe C (UA );
}
}
N = {
System: TMP [1]. tolowercase (),
Version: TMP [2]. Replace (/(\ _ | \.)/ig, '.'). tolowercase (),
Browser: browser? Browser [1]. tolowercase (): 'apple/WebKit ',
IOS: IOS
}
Return N ;}