赞
踩
pc浏览器(兼容IE11)
var Sys = {}; var ua = navigator.userAgent.toLowerCase(); var s; (s = ua.match(/rv:([\d.]+)\) like gecko/)) ? Sys.ie = s[1] : (s = ua.match(/msie ([\d\.]+)/)) ? Sys.ie = s[1] : (s = ua.match(/edge\/([\d\.]+)/)) ? Sys.edge = s[1] : (s = ua.match(/firefox\/([\d\.]+)/)) ? Sys.firefox = s[1] : (s = ua.match(/(?:opera|opr).([\d\.]+)/)) ? Sys.opera = s[1] : (s = ua.match(/chrome\/([\d\.]+)/)) ? Sys.chrome = s[1] : (s = ua.match(/version\/([\d\.]+).*safari/)) ? Sys.safari = s[1] : 0; // 根据关系进行判断 if (Sys.ie) return ('IE: ' + Sys.ie); if (Sys.edge) return ('EDGE: ' + Sys.edge); if (Sys.firefox) return ('Firefox: ' + Sys.firefox); if (Sys.chrome) return ('Chrome: ' + Sys.chrome); if (Sys.opera) return ('Opera: ' + Sys.opera); if (Sys.safari) return ('Safari: ' + Sys.safari); return 'Unkonwn';
手机端
- this.isAndroid = window.navigator.userAgent.indexOf('Android') > -1 || window.navigator.userAgent.indexOf('Adr') > -1
- this.isIos = !!window.navigator.userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)
记录一下,能帮助到大家也是极好的!
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。