码迷,mamicode.com
首页 > 其他好文 > 详细

获取各浏览器的版本号

时间:2018-08-13 00:45:26      阅读:212      评论:0      收藏:0      [点我收藏+]

标签:chrome   javascrip   mod   获取   firefox   ide   navigator   asc   regex   

browser: {
        chrome: /chrome\/(\d+\.\d+)/i.test(navigator.userAgent) ? +RegExp["\x241"] : undefined,
        firefox: /firefox\/(\d+\.\d+)/i.test(navigator.userAgent) ? +RegExp["\x241"] : undefined,
        ie: /msie (\d+\.\d+)|Trident/i.test(navigator.userAgent) ? (document.documentMode || +RegExp["\x241"]) : undefined,
        isGecko: /gecko/i.test(navigator.userAgent) && !/like gecko/i.test(navigator.userAgent),
        isWebkit: /webkit/i.test(navigator.userAgent),
        opera: /opera(\/| )(\d+(\.\d+)?)(.+?(version\/(\d+(\.\d+)?)))?/i.test(navigator.userAgent) ? +(RegExp["\x246"] || RegExp["\x242"]) : undefined,
        safari: /(\d+\.\d)?(?:\.\d)?\s+safari\/?(\d+\.\d+)?/i.test(navigator.userAgent) && !/chrome/i.test(navigator.userAgent) ? +(RegExp["\x241"] || RegExp["\x242"]) : undefined,
        isSogouIE: ((navigator.userAgent.toLowerCase()).indexOf("msie") > 0) && ((navigator.userAgent.toLowerCase()).indexOf("se") > 0) && ((navigator.userAgent.toLowerCase()).indexOf("360se") == -1),
        isBaidu: /BIDUBrowser/i.test(navigator.userAgent),
        edge: /edge\/(\d+)/i.test(navigator.userAgent) ? +RegExp["\x241"] : undefined
    }

  

获取各浏览器的版本号

标签:chrome   javascrip   mod   获取   firefox   ide   navigator   asc   regex   

原文地址:https://www.cnblogs.com/caoruichun/p/9465550.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!