js判斷客戶端是不是IOS或者是Androidhtml
//若是返回true 則說明是Android
function is_weixin() { var ua = window.navigator.userAgent.toLowerCase(); if (ua.match(/MicroMessenger/i) == 'micromessenger') { return true; } else { return false; } }
js判斷手機操做系統(ios或者是Android)ios
$(function () { var u = navigator.userAgent, app = navigator.appVersion; var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; //g var isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios終端 if (isAndroid) { //這個是安卓操做系統 } if (isIOS) { //這個是ios操做系統 } });
js判斷是不是電腦端app
//若是返回的是false說明當前操做系統是手機端,若是返回的是true則說明當前的操做系統是電腦端
function IsPC() { var userAgentInfo = navigator.userAgent; var Agents = ["Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"]; var flag = true; for (var v = 0; v < Agents.length; v++) { if (userAgentInfo.indexOf(Agents[v]) > 0) { flag = false; break; } } return flag; }
參考地址:http://www.cnblogs.com/zyjzz/p/4996926.html