标签:pod div false match mac os ipo ipa navigator style
1. 判断是ios还是android
let u = navigator.userAgent,
let isAndroid = u.indexOf(‘Android‘) > -1 || u.indexOf(‘Linux‘) > -1; //g let isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端 if (isAndroid) { //这个是安卓操作系统 } if (isIOS) { //这个是ios操作系统 }
2. 判断是PC端还是M端
let userAgent = navigator.userAgent; let Agents = ["Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"]; let flag = true; for (let i in Agents) { if (userAgent.indexOf(Agents[i]) > -1) { flag = false; break; } } if(flag){ //这个是PC端 }else{ //这个是M端 }
标签:pod div false match mac os ipo ipa navigator style
原文地址:https://www.cnblogs.com/223zzm/p/11747079.html