Today I will introduce to you how to use js to judge mobile client platform and system platform:
<script type="text/javascript">//Mobile-side judges the browser and operating system platform function checkPlatform(){if(/android/i.test(navigator.userAgent)){document.write("This is Android'browser.");//This is the browser under the Android platform}if(/(iPhoneiPadiPodiOS)/i.test(navigator.userAgent)){document.write("This is iOS'browser.");//This is the browser under the iOS platform}if(/Linux/i.test(navigator.userAgent)){document.write("This is Linux'browser.");//This is the browser under the Linux platform}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 the browser under the WeChat platform}} $(document).ready(function(){ alert(navigator.platform); checkPlatform(); });</script>Note that the above code uses jquery. JQuery needs to be loaded before it can be run. Of course you can delete the trigger function
I won’t make judgments on the PC operating system platform here. I will also talk about the method of how to judge. For example, you can obtain the operating system platform by using document.write(navigator.platform); Win32 will be displayed under win32; Win64 will be displayed under Win64, etc.
Below, the editor of Wulin.com will add some good functions to you
<script type="text/javascript">var browser = {versions : function () {var u = navigator.userAgent,app = navigator.appVersion;return {trident : u.indexOf('Trident') > -1,presto : u.indexOf('Presto') > -1,webKit : u.indexOf('AppleWebKit') > -1,gecko : u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -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 browser");}</script>Tested personally, very useful.