[JS]用js来判断用户端浏览器(判断QQ浏览器、谷歌浏览器)方法
[JS]用js来判断用户端浏览器(判断QQ浏览器、谷歌浏览器)方法
[JS]用js来判断用户端浏览器(判断QQ浏览器、谷歌浏览器)方法
- function getBrowserInfo(){
- var ua = navigator.userAgent.toLocaleLowerCase();
- var browserType=null;
- if (ua.match(/msie/) != null || ua.match(/trident/) != null) {
- browserType = "IE";
- browserVersion = ua.match(/msie ([\d.]+)/) != null ? ua.match(/msie ([\d.]+)/)[1] : ua.match(/rv:([\d.]+)/)[1];
- } else if (ua.match(/firefox/) != null) {
- browserType = "火狐";
- }else if (ua.match(/ubrowser/) != null) {
- browserType = "UC";
- }else if (ua.match(/opera/) != null) {
- browserType = "欧朋";
- } else if (ua.match(/bidubrowser/) != null) {
- browserType = "百度";
- }else if (ua.match(/metasr/) != null) {
- browserType = "搜狗";
- }else if (ua.match(/tencenttraveler/) != null || ua.match(/qqbrowse/) != null) {
- browserType = "QQ";
- }else if (ua.match(/maxthon/) != null) {
- browserType = "遨游";
- }else if (ua.match(/chrome/) != null) {
- var is360 = _mime("type", "application/vnd.chromium.remoting-viewer");
- function _mime(option, value) {
- var mimeTypes = navigator.mimeTypes;
- for (var mt in mimeTypes) {
- if (mimeTypes[mt][option] == value) {
- return true;
- }
- }
- return false;
- }
- if(is360){
- browserType = '360';
- }else{
- $('html').css("zoom",".80");
- }
- }else if (ua.match(/safari/) != null) {
- browserType = "Safari";
- }
- }
来源:https://blog.csdn.net/zlf_php/article/details/78959234
另一种判断:
- /Safari/.test(navigator.userAgent) && !/Chrome/.test(navigator.userAgent);
热门文章推荐
- [JS]window.location获取url各项参数详解
- [JS]jQuery,javascript获得网页的高度和宽度
- [JS]视频弹窗视频弹出层videoLightBox(含三种播放器的用法)
- [JS]JS提交中文encodeURI两次转码
- [JS]js版方面encodeURI转码和decodeURI解码的用法实例
- [JS]js取当前机子的时间戳实例
- [JS]AES加密(基于crypto-js)PHP后端解密
- [JS]data:image/png;base64写法的用途及说明
请稍候...