1、 判断浏览器是pc设备还是移动设备
if(window.navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i)) {// return true; // 移动端alert("移动设备");}else{// return false; // PC端alert("pc设备");}
2、判断浏览器是pc环境
3、判断浏览器是手机端微信环境
4 判断浏览器是不是在手机上非微信上打开的
//平台、设备和操作系统var system = {win: false,mac: false,xll: false,ipad: false};//检测平台var p = navigator.platform;system.win = p.indexOf("Win") == 0;system.mac = p.indexOf("Mac") == 0;system.x11 = (p == "X11") || (p.indexOf("Linux") == 0);system.ipad = (navigator.userAgent.match(/iPad/i) != null) ? true : false;//跳转语句,如果是手机访问就自动跳转到页面if (system.win || system.mac || system.xll || system.ipad) {alert("当前为PC环境");} else {var ua = navigator.userAgent.toLowerCase();if(ua.match(/MicroMessenger/i)=="micromessenger") {alert("当前为手机端微信环境");} else {alert("当前为手机端非微信环境");}}
如果觉得《js判断当前浏览器的环境是微信 pc 还是手机端非微信环境》对你有帮助,请点赞、收藏,并留下你的观点哦!