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:
- You now have access to the global object
theBrowser
, which you can use in the following ways:
theBrowsername; // 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. theBrowserversion; // This is the browser's version – a string with digits // and dots. theBrowser; // This will return true if the site is viewed with // Google Chrome. theBrowser; // integer. Instead of `version` you can specify the // integers `minVersion` and/or `maxVersion`. theBrowser;
License
This software is released under the terms of the MIT License.