JS 判断是否移动端
javascript 判断是否移动端,代码如下
javascript 判断是否移动端,代码如下:
function isMobile() {
const userAgentInfo = navigator.userAgent
const Agents = [
'Android',
'iPhone',
'iPad',
'iPod'
]
let flag = false
for (let v = 0; v < Agents.length; v++) {
if (userAgentInfo.indexOf(Agents[v]) > 0) {
flag = true
break
}
}
return flag
}