Skip to content
This repository has been archived by the owner on Aug 21, 2023. It is now read-only.

b12-archive/the-browser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This package is deprecated! Please use detect-browser instead.


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.

About

(DEPRECATED) Simple browser detection.

Resources

License

Stars

Watchers

Forks

Packages

No packages published