huoxiangdong / Blog

学习记录
0 stars 0 forks source link

移动端判断 #70

Open huoxiangdong opened 6 years ago

huoxiangdong commented 6 years ago
function isMobile() {
  let ua = navigator.userAgent;
  return ua.match(/(Android)[\s\/]+([\d\.]+)/) !== null
    || ua.match(/(iPad|iPhone|iPod)\s+OS\s([\d_\.]+)/) !== null
    || ua.match(/(Windows\s+Phone)\s([\d\.]+)/) !== null;
}