jQuery 插件: 识别浏览器, 判断浏览器类型和版本, browser detection




<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-browser/0.1.0/jquery.browser.min.js"></script>

判断 IE ,返回 true 或者 false,支持所有IE浏览器,包括IE 11


判断 WebKit 浏览器 (Safari, Chrome and Opera 15+),返回 true 或者 false


判断 Firefox 浏览器,返回 true 或者 false




检查浏览器 arbitrary User-Agents



所以也可以通过 jQBrowser.uaMatch().chrome 来判断是否是chrome浏览器。

  • Detect specifically Windows, Mac, Linux, iPad, iPhone, iPod, Android, Kindle, BlackBerry, Chrome OS, and Windows Phone useragents
    	$.browser["windows phone"]

    Alternatively, you can detect for generic classifications such as desktop or mobile

    // User Agent for Firefox on Windows
    User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0
    $.browser.desktop // Returns true as a boolean
    // User Agent for Safari on iPhone
    User-Agent: Mozilla/5.0(iPhone; CPU iPhone OS 7_0_3 like Mac OS X; en-us) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11B508 Safari/9537.53
    $.browser.mobile // Returns true as a boolean
  • Detect the browser's major version
    // User Agent for Chrome
    // Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1664.3 Safari/537.36
    $.browser.versionNumber // Returns 32 as a number
  • Support for new useragent on IE 11
  • Support for Microsoft Edge
  • Support for WebKit based Opera browsers
  • Added testing using PhantomJS and different browser user agents




本文:jQuery 插件: 识别浏览器, 判断浏览器类型和版本, browser detection




Add a Comment

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.