This package has been deprecated

Author message:

This package is deprecated. Please use git.io/detect-browser instead

the-browser

0.3.2 • Public • Published

the-browser.js

Simple browser detection.

– by Studio B12 GmbH

We all know browser sniffing is bad. But admit it, there are valid situations when you have to use it. Displaying helpful messages. Gathering statistics. Even the puritan principles of progressive enhancement sometimes require switching on some un-feature-detectable fancy for certain browsers.

That said, we present a browser detection plugin. As simple as it can get.

Usage

  • Download the script. You can use bower:
bower install the-browser
  • Include the script before yours:
<script src="bower_components/the-browser/dist/the-browser.js"></script>
  • You now have access to the global object theBrowser, which you can use in the following ways:
theBrowser.name;                            // This property holds the browser's name. "Internet
                                            // Explorer" and "Opera" are normalized, as they try to
                                            // spoof browser sniffing. Other browsers' names come
                                            // fresh from parsing the userAgent string, normally
                                            // title-cased.
 
 
theBrowser.version;                         // This is the browser's version – a string with digits
                                            // and dots.
 
 
theBrowser.is('Chrome');                    // This will return true if the site is viewed with
                                            // Google Chrome.
 
 
theBrowser.is({ name: 'Internet Explorer'   // This will return true if the site is viewed with
              , version: '8.0'              // IE 8.0, otherwise false. `version` can also be an
              });                           // integer. Instead of `version` you can specify the
                                            // integers `minVersion` and/or `maxVersion`.
 
 
theBrowser.is([ { name: 'Internet Explorer' // Array syntax for `theBrowser.is()` is also supported.
                , maxVersion: 8             // This will return true when the site is viewed either
                }                           // with IE 8 or earlier, or with Firefox 3 or earlier.
              , { name: 'Firefox'
                , maxVersion: 3              
                }                
              ]);

License

This software is released under the terms of the MIT License.

Readme

Keywords

none

Package Sidebar

Install

npm i the-browser

Weekly Downloads

2

Version

0.3.2

License

MIT

Last publish

Collaborators

  • tomekwi