📜  js 如果是移动浏览器 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:30.710000             🧑  作者: Mango

代码示例1
// credit to Timothy Huang for this regex test: 
// https://dev.to/timhuang/a-simple-way-to-detect-if-browser-is-on-a-mobile-device-with-javascript-44j3
if(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)){
  return true
}
else{
  return false
}