首页 > 代码库 > 判断设备(PC,安Android,iOS)

判断设备(PC,安Android,iOS)

//判断是不是PCfunction IsPC() {var userAgentInfo = navigator.userAgent;var Agents = new Array("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;}

  

//判断是什么移动端function getOSType() {if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {return "IOS";} else if (/(Android)/i.test(navigator.userAgent)) {return "Android";} else {return "other";};}

  

判断设备(PC,安Android,iOS)