关于浏览器及系统的判断

主要是根据   navigator.userAgent.toLowerCase

userAgent 属性是一个只读的字符串,声明了浏览器用于 HTTP 请求的用户代理头的值   

返回的是个字符串,各个浏览器详情值:https://www.cnblogs.com/c2g5201314/p/12315604.html

var ua = navigator.userAgent.toLowerCase(); //以下都以此值判断 

一、pc与mobile

var mobile = /mobile/gi.test(ua);   //true  当前为mobile

console.log(document.webkitHidden); //false  非移动端

二、android 与 ios

var isAndroid = ua.indexOf('Android') > -1 || ua.indexOf('Adr') > -1; //  true  android

或者: 

 if(ua.indexOf("android")!=-1){  

   console.log("为android") 

 }

var isiOS = !!ua.match(/(i[^;]+;( U;)? CPU.+Mac OS X/);  //ios

原文地址:https://www.cnblogs.com/redFeather/p/15019257.html