Determine the JS code of the operating system and browser
The Navigator.userAgent:userAgent property is a read-only string that declares the value of the user agent header used by the browser for HTTP requests.
The Navigator.platform:platform property is a read-only string that declares the operating system and/or hardware platform on which the browser is running.
Determine the operating system type
Win operating system
1 Navigator.platform = = "Win32"2 navigator.platform = = "Windows"
Win2000 Operating System
1 /windows NT 5.0/i.test (navigator.useragent)
WinXP operating System
1 /windows NT 5.1/i.test (navigator.useragent)
WIN2003 Operating System
1 /windows NT 5.2/i.test (navigator.useragent)
WinVista Operating System
1 /windows NT 6.0/i.test (navigator.useragent)
Win7 Operating System
1 /windows NT 6.1/i.test (navigator.useragent)
Mac operating System
1 Navigator.platform = = "mac68k"2 navigator.platform = = "MACPPC"3 navigator.platform = = " Macintosh "4 navigator.platform = =" Macintel "
UNIX Operating system
1 navigator.platform = = "X11"
Linux operating system
1 /linux/i.test (navigator.useragent)
Andorid Operating System
1 if (/linux/i.test (navigator. useragent) {2 if(/android/i.test (navigator.useragent). toLowerCase ())) {3 return "Android"; 4 }5 }
Determine browser type
IE Browser:
1 /ie/i.test (Navigator.userAgent.toLowerCase ());
Firefox browser
1 /firefox/i.test (Navigator.userAgent.toLowerCase ());
Google Chrome
1 /chrome/i.test (Navigator.userAgent.toLowerCase ());
Opera browser
1 /opera/i.test (Navigator.userAgent.toLowerCase ());
Safari browser
1 /safari/i.test (Navigator.userAgent.toLowerCase ());
Browser
1 /micromessenger/i.test (Navigator.userAgent.toLowerCase ());
Use JS to determine the operating system and browser type