这个浏览器终端分析,还是非常不错的,拷在这学习看看。。

    /** * 浏览器解析,浏览器、Node.js皆可 * https://github.com/mumuy/browser */ (function (root, factory) { if (typeof define === 'function' && define.amd) { // AMD define(factory) } else if (typeof exports === 'object') { // Node, CommonJS-like module.exports = factory() } else { // Browser globals (root is window) root.Browser = factory() } }(this, function () { var _window = window||{}; var _navigator = navigator||{}; return function (userAgent) { var u = userAgent || _navigator.userAgent; var _this = this; var match = { //内核 'Trident': u.indexOf('Trident') > -1 || u.indexOf('NET CLR') > -1, 'Presto': u.indexOf('Presto') > -1, 'WebKit': u.indexOf('AppleWebKit') > -1, 'Gecko': u.indexOf('Gecko/') > -1, //浏览器 'Safari': u.indexOf('Safari') > -1, 'Chrome': u.indexOf('Chrome') > -1 || u.indexOf('CriOS') > -1, 'IE': u.indexOf('MSIE') > -1 || u.indexOf('Trident') > -1, 'Edge': u.indexOf('Edge') > -1, 'Firefox': u.indexOf('Firefox') > -1 || u.indexOf('FxiOS') > -1, 'Firefox Focus': u.indexOf('Focus') > -1, 'Chromium': u.indexOf('Chromium') > -1, 'Opera': u.indexOf('Opera') > -1 || u.indexOf('OPR') > -1, 'Vivaldi': u.indexOf('Vivaldi') > -1, 'Yandex': u.indexOf('YaBrowser') > -1, 'Kindle': u.indexOf('Kindle') > -1 || u.indexOf('Silk/') > -1, '360': u.indexOf('360EE') > -1 || u.indexOf('360SE') > -1, 'UC': u.indexOf('UC') > -1 || u.indexOf(' UBrowser') > -1, 'QQBrowser': u.indexOf('QQBrowser') > -1, 'QQ': u.indexOf('QQ/') > -1, 'Baidu': u.indexOf('Baidu') > -1 || u.indexOf('BIDUBrowser') > -1, 'Maxthon': u.indexOf('Maxthon') > -1, 'Sogou': u.indexOf('MetaSr') > -1 || u.indexOf('Sogou') > -1, 'LBBROWSER': u.indexOf('LBBROWSER') > -1, '2345Explorer': u.indexOf('2345Explorer') > -1, 'TheWorld': u.indexOf('TheWorld') > -1, 'XiaoMi': u.indexOf('MiuiBrowser') > -1, 'Quark': u.indexOf('Quark') > -1, 'Qiyu': u.indexOf('Qiyu') > -1, 'Wechat': u.indexOf('MicroMessenger') > -1, 'Taobao': u.indexOf('AliApp(TB') > -1, 'Alipay': u.indexOf('AliApp(AP') > -1, 'Weibo': u.indexOf('Weibo') > -1, 'Douban': u.indexOf('com.douban.frodo') > -1, 'Suning': u.indexOf('SNEBUY-APP') > -1, 'iQiYi': u.indexOf('IqiyiApp') > -1, //系统或平台 'Windows': u.indexOf('Windows') > -1, 'Linux': u.indexOf('Linux') > -1 || u.indexOf('X11') > -1, 'Mac OS': u.indexOf('Macintosh') > -1, 'Android': u.indexOf('Android') > -1 || u.indexOf('Adr') > -1, 'Ubuntu': u.indexOf('Ubuntu') > -1, 'FreeBSD': u.indexOf('FreeBSD') > -1, 'Debian': u.indexOf('Debian') > -1, 'Windows Phone': u.indexOf('IEMobile') > -1 || u.indexOf('Windows Phone')>-1, 'BlackBerry': u.indexOf('BlackBerry') > -1 || u.indexOf('RIM') > -1, 'MeeGo': u.indexOf('MeeGo') > -1, 'Symbian': u.indexOf('Symbian') > -1, 'iOS': u.indexOf('like Mac OS X') > -1, 'Chrome OS': u.indexOf('CrOS') > -1, 'WebOS': u.indexOf('hpwOS') > -1, //设备 'Mobile': u.indexOf('Mobi') > -1 || u.indexOf('iPh') > -1 || u.indexOf('480') > -1, 'Tablet': u.indexOf('Tablet') > -1 || u.indexOf('Pad') > -1 || u.indexOf('Nexus 7') > -1 }; //修正 if (match['Mobile']) { match['Mobile'] = !(u.indexOf('iPad') > -1); } else if (_window.showModalDialog && _window.chrome) { match['360'] = true; } //基本信息 var hash = { engine: ['WebKit', 'Trident', 'Gecko', 'Presto'], browser: ['Safari', 'Chrome', 'Edge', 'IE', 'Firefox', 'Firefox Focus', 'Chromium', 'Opera', 'Vivaldi', 'Yandex', 'Kindle', '360', 'UC', 'QQBrowser', 'QQ', 'Baidu', 'Maxthon', 'Sogou', 'LBBROWSER', '2345Explorer', 'TheWorld', 'XiaoMi', 'Quark', 'Qiyu', 'Wechat', 'Taobao', 'Alipay', 'Weibo', 'Douban','Suning', 'iQiYi'], os: ['Windows', 'Linux', 'Mac OS', 'Android', 'Ubuntu', 'FreeBSD', 'Debian', 'iOS', 'Windows Phone', 'BlackBerry', 'MeeGo', 'Symbian', 'Chrome OS', 'WebOS'], device: ['Mobile', 'Tablet'] }; _this.device = 'PC'; _this.language = (function () { var g = (_navigator.browserLanguage || _navigator.language); var arr = g.split('-'); if (arr[1]) { arr[1] = arr[1].toUpperCase(); } return arr.join('_'); })(); for (var s in hash) { for (var i = 0; i < hash[s].length; i++) { var value = hash[s][i]; if (match[value]) { _this[s] = value; } } } //系统版本信息 var osVersion = { 'Windows': function () { var v = u.replace(/^.*Windows NT ([\d.]+);.*$/, '$1'); var hash = { '6.4': '10', '6.3': '8.1', '6.2': '8', '6.1': '7', '6.0': 'Vista', '5.2': 'XP', '5.1': 'XP', '5.0': '2000' }; return hash[v] || v; }, 'Android': function () { return u.replace(/^.*Android ([\d.]+);.*$/, '$1'); }, 'iOS': function () { return u.replace(/^.*OS ([\d_]+) like.*$/, '$1').replace(/_/g, '.'); }, 'Debian': function () { return u.replace(/^.*Debian\/([\d.]+).*$/, '$1'); }, 'Windows Phone': function () { return u.replace(/^.*Windows Phone( OS)? ([\d.]+);.*$/, '$2'); }, 'Mac OS': function () { return u.replace(/^.*Mac OS X ([\d_]+).*$/, '$1').replace(/_/g, '.'); }, 'WebOS': function () { return u.replace(/^.*hpwOS\/([\d.]+);.*$/, '$1'); } } _this.osVersion = ''; if (osVersion[_this.os]) { _this.osVersion = osVersion[_this.os](); if (_this.osVersion == u) { _this.osVersion = ''; } } //浏览器版本信息 var version = { 'Safari': function () { return u.replace(/^.*Version\/([\d.]+).*$/, '$1'); }, 'Chrome': function () { return u.replace(/^.*Chrome\/([\d.]+).*$/, '$1').replace(/^.*CriOS\/([\d.]+).*$/, '$1'); }, 'IE': function () { return u.replace(/^.*MSIE ([\d.]+).*$/, '$1').replace(/^.*rv:([\d.]+).*$/, '$1'); }, 'Edge': function () { return u.replace(/^.*Edge\/([\d.]+).*$/, '$1'); }, 'Firefox': function () { return u.replace(/^.*Firefox\/([\d.]+).*$/, '$1').replace(/^.*FxiOS\/([\d.]+).*$/, '$1'); }, 'Firefox Focus': function () { return u.replace(/^.*Focus\/([\d.]+).*$/, '$1'); }, 'Chromium': function () { return u.replace(/^.*Chromium\/([\d.]+).*$/, '$1'); }, 'Opera': function () { return u.replace(/^.*Opera\/([\d.]+).*$/, '$1').replace(/^.*OPR\/([\d.]+).*$/, '$1'); }, 'Vivaldi': function () { return u.replace(/^.*Vivaldi\/([\d.]+).*$/, '$1'); }, 'Yandex': function () { return u.replace(/^.*YaBrowser\/([\d.]+).*$/, '$1'); }, 'Kindle': function () { return u.replace(/^.*Version\/([\d.]+).*$/, '$1'); }, 'Maxthon': function () { return u.replace(/^.*Maxthon\/([\d.]+).*$/, '$1'); }, 'QQBrowser': function () { return u.replace(/^.*QQBrowser\/([\d.]+).*$/, '$1'); }, 'QQ': function () { return u.replace(/^.*QQ\/([\d.]+).*$/, '$1'); }, 'Baidu': function () { return u.replace(/^.*BIDUBrowser[\s\/]([\d.]+).*$/, '$1'); }, 'UC': function () { return u.replace(/^.*UC?Browser\/([\d.]+).*$/, '$1'); }, 'Sogou': function () { return u.replace(/^.*SE ([\d.X]+).*$/, '$1').replace(/^.*SogouMobileBrowser\/([\d.]+).*$/, '$1'); }, '2345Explorer': function () { return u.replace(/^.*2345Explorer\/([\d.]+).*$/, '$1'); }, 'TheWorld': function () { return u.replace(/^.*TheWorld ([\d.]+).*$/, '$1'); }, 'XiaoMi': function () { return u.replace(/^.*MiuiBrowser\/([\d.]+).*$/, '$1'); }, 'Quark': function () { return u.replace(/^.*Quark\/([\d.]+).*$/, '$1'); }, 'Qiyu': function () { return u.replace(/^.*Qiyu\/([\d.]+).*$/, '$1'); }, 'Wechat': function () { return u.replace(/^.*MicroMessenger\/([\d.]+).*$/, '$1'); }, 'Taobao': function () { return u.replace(/^.*AliApp\(TB\/([\d.]+).*$/, '$1'); }, 'Alipay': function () { return u.replace(/^.*AliApp\(AP\/([\d.]+).*$/, '$1'); }, 'Weibo': function () { return u.replace(/^.*weibo__([\d.]+).*$/, '$1'); }, 'Douban': function () { return u.replace(/^.*com.douban.frodo\/([\d.]+).*$/, '$1'); }, 'Suning': function () { return u.replace(/^.*SNEBUY-APP([\d.]+).*$/, '$1'); }, 'iQiYi': function () { return u.replace(/^.*IqiyiVersion\/([\d.]+).*$/, '$1'); } }; _this.version = ''; if (version[_this.browser]) { _this.version = version[_this.browser](); if (_this.version == u) { _this.version = ''; } } //修正 if (_this.browser == 'Edge') { _this.engine = 'EdgeHTML'; } else if (_this.browser == 'Chrome' && parseInt(_this.version) > 27) { _this.engine = 'Blink'; } else if (_this.browser == 'Opera' && parseInt(_this.version) > 12) { _this.engine = 'Blink'; } else if (_this.browser == 'Yandex') { _this.engine = 'Blink'; } }; })); 

用户终端浏览器的判断源代码写法示例相关推荐

  1. 用js来判断用户端浏览器(判断QQ浏览器、谷歌浏览器)方法

    用js来判断用户端浏览器(判断QQ浏览器.谷歌浏览器)方法 function getBrowserInfo(){ var ua = navigator.userAgent.toLocaleLowerC ...

  2. js网页判断移动终端浏览器版本信息是安卓还是苹果ios,判断在微信浏览器跳转不同页面,生成二维码...

    一个二维码,扫描进入网页,自动识别下载苹果和安卓客户端,判断网页如下,(只有苹果的微信不能自动跳转)所以加个微信判断. <!DOCTYPE html> <html><he ...

  3. Go语言实践[回顾]教程06--通过时间判断时辰的示例【上】

    Go语言实践[回顾]教程06--通过时间判断时辰的示例[上] 示例项目的需求 实现示例需求的源代码 使用 if 判断逻辑实现的源代码 使用 if else if 判断逻辑实现的源代码 使用 switc ...

  4. 移动端IOS和androi及浏览器js判断[转载]

    转载自:http://www.niutifa.com/?p=561 移动端IOS和androi及浏览器js判断: <script type="text/javascript" ...

  5. 在用户控件中用户登录后台脚本判断

    在用户控件中用户登录后台脚本判断写法  if (!IsPostBack)         {                         imagelogin.Attributes.Add(&qu ...

  6. 微信小程序开发——小程序API获取用户位置及异常流处理完整示例

    前言: 小程序需要添加一个定位功能,主要的就是获取用户位置的经纬度,然后根据用户经纬度进行一些判断操作. 在小程序提供的Api中,获取用户定位信息的主要Api是 wx.getLocation(obj) ...

  7. javaweb关于用户是否登录全局判断,没有登录跳转到登录界面

    javaweb关于用户是否登录全局判断,没有登录跳转到登录界面 有这样一个需求,用户密码登录网站,在session中保留了用户的信息,但是用户很长时间没有再操作该界面,用户的session则被浏览器清 ...

  8. [完美]原生JS获取浏览器版本判断--支持Edge,IE,Chrome,Firefox,Opera,Safari,以及各种使用Chrome和IE混合内核的浏览器...

    [完美]原生JS获取浏览器版本判断--支持Edge,IE,Chrome,Firefox,Opera,Safari,以及各种使用Chrome和IE混合内核的浏览器 原文:[完美]原生JS获取浏览器版本判 ...

  9. linux查看当前用户终端,Linux----基本命令的使用(vi命令,查看文件内容,显示进程,切换用户等)...

    1.vi是linux系统上经常使用的一个文本编辑器,其有三种模式:命令模式.编辑模式(插入模式).末行模式. 命令模式-->编辑模式:"i a o I A O"linux 编 ...

最新文章

  1. SAP CRM WebClient UI的on_new_focus应该怎么理解
  2. 【视觉盛宴二】长见识了,你见过BGA封装芯片的横截面吗!
  3. VS封装给Unity使用的DLL
  4. 安卓学习第10课——listview
  5. java 代码解析工具_改善 Java 代码质量的工具与方法
  6. 使用javaGUI编写检测是否有网
  7. Ubuntu20.04下opencv的安装
  8. 前端安全 XSS跨站脚本攻击-CSRF跨站请求伪造攻击
  9. openwrt的ipk包开发
  10. 闪迪U盘插入电脑后,系统能识别到插入,但在我的电脑中没有显示的解决方法
  11. 20155305《网络对抗》信息搜集与漏洞扫描
  12. 厦门大学353卫生综合考研参考书目
  13. Interpreter(解释器)
  14. 商标注册中的字体也会侵权?这是真事
  15. uni-app animation动画
  16. France beat Croatia 4-2 in World Cup final
  17. 【读书笔记】《博弈论》
  18. pip更换源,换成国内镜像
  19. 微信小程序例子——点击文字实现页面跳转
  20. 《攻防世界》forgot栈空间题

热门文章

  1. QQ尾巴病毒的发送原理分析
  2. 达内2018前端设计相关最新
  3. 第10节:文件操作/os模块/shutil模块/递归算法原理
  4. bip39:使用bip39生成助记词
  5. 干货分享:如何创造完整的核心游戏体验
  6. QG工作室2010年招新通知(附报名表)
  7. 代理IP对于直播人气有多大作用-国内多ip站群
  8. 中望3D 2021 “拔模”命令使用曲面做中性面
  9. 蓝桥杯每日一练-----纸张尺寸
  10. 05-数据库_JDBC