Js Method for Determining the operating system and browser of the mobile browser, js judgment
Today, we will introduce how to use js to determine the mobile client platform and System Platform:
<Script type = "text/javascript"> // determine the function checkPlatform () {if (/android/I. test (navigator. userAgent) {document. write ("This is Android 'browser. "); // This is the Android browser} if (/(iPhoneiPadiPodiOS)/I. test (navigator. userAgent) {document. write ("This is iOS 'browser. "); // This is the browser on the iOS platform} if (/Linux/I. test (navigator. userAgent) {document. write ("This is Linux 'browser. "); // This is a Linux Browser} if (/Linux/I. test (navigator. platform) {document. write ("This is Linux operating system. "); // This is the Linux operating system platform} if (/MicroMessenger/I. test (navigator. userAgent) {document. write ("This is MicroMessenger 'browser. "); // This is a platform browser }}$ (document ). ready (function () {alert (navigator. platform); checkPlatform () ;}); </script>
Note that the above Code uses jquery. Jquery can be run only when it is loaded. Of course, you can delete the trigger function.
Here we will not judge the pc-side operating system platform. Let's talk about how to judge it. For example, we can use document. write (navigator. platform) to obtain the operating system platform. Win32 is displayed under Win32, and Win64 is displayed under Win64.
Below is a small series of helper's house that will provide you with a few good functions.
<Script type = "text/javascript"> var browser = {versions: function () {var u = navigator. userAgent, app = navigator. appVersion; return {trident: u. indexOf ('think')>-1, presto: u. indexOf ('presto ')>-1, webKit: u. indexOf ('applewebkit ')>-1, gecko: u. indexOf ('gecko ')>-1 & u. indexOf ('html ') =-1, mobile :!! U. match (/AppleWebKit. * Mobile. */) | !! U. match (/AppleWebKit/), ios :!! U. match (/\ (I [^;] +; (U ;)? CPU. + Mac OS X/), android: u. indexOf ('android')>-1 | u. indexOf ('linux ')>-1, iPhone: u. indexOf ('iphone ')>-1 | u. indexOf ('mac')>-1, iPad: u. indexOf ('ipad ')>-1, webApp: u. indexOf ('safari ') =-1, QQbrw: u. indexOf ('mqqbrowser ')>-1, weiXin: u. indexOf ('micromessenger ')>-1, ucLowEnd: u. indexOf ('ucweb7. ')>-1, ucSpecial: u. indexOf ('rv: 1.2.3.4 ')>-1, ucweb: function () {try {return parseFloat (u. match (/ucweb \ d + \. \ d +/gi ). toString (). match (/\ d + \. \ d + /). toString ()> = 8.2} catch (e) {if (u. indexOf ('uc')>-1) {return true;} else {return false ;}}(), Symbian: u. indexOf ('symbian ')>-1, ucSB: u. indexOf ('Firefox/1. ')>-1 };}()} if (browser. versions. QQbrw) {document. write ("qq Browser");} else {document. write ("other browsers") ;}</script>
It is very easy to use.