Objects used in the program to determine client information
The requirement is not high, so it is relatively simple and not necessarily accurate.
In the game, you only need to determine whether Internet Explorer, Internet Explorer 6, and mobile phone functions.
This object can be used to determine the client operating system type, browser type, whether the client machine is a computer or mobile phone type, whether the access protocol is HTTP or FILE
Here, we only use it to determine that if the three systems are not windows, Mac, or Unix, they are mobile phones.
When the mobile phone is determined, the game automatically picks up the sun by default.
// User object, used to store the user's browser, operating system, and client type
$ User = function (){
Var platform = navigator. platform, userAgent = navigator. userAgent,
IsWin = (platform = 'win32 '| platform = "Windows "),
IsMac = (platform = 'mac68k' | platform = 'macppc '| platform = 'macintosh '),
IsUnix = (platform = 'x11 '&&! IsWin &&! IsMac ),
IsPC = isWin | isMac | isUnix;
Return {// the browser determines IE :!! (Window. attachEvent &&! Window. opera ),! -[1,]
Browser: {IE :!! (Window. attachEvent &&! Window. opera ),
IE6 :!! (Window. attachEvent &&! Window. opera )&&! Window. XMLHttpRequest,
Opera :!! Window. opera,
WebKit: userAgent. indexOf ('applewebkit/')>-1,
Gecko: userAgent. indexOf ('gecko ')>-1 & userAgent. indexOf ('khtml') =-1
},
// Operating System
System: {Win: isWin, Mac: isMac, Unix: isUnix },
// Client Machine Type
Client: {PC: isPC, Mobile :! IsPC },
// Obtain the address bar protocol, http Representation
HTTP: location. protocol. toLowerCase () = 'HTTP :'? 1:0
}
}()
Original: http://www.lonelystar.org/post/4.html