browsertype.js
v1.0.6
Published
An automated detection library for the current browser.
Readme
BrowserType.js
An automated detection library for the current browser.
Installation
Include the script somehow in your page. You can retrieve it using the following methods:
Package manager:
$ npm install browsertype.js --save
$ yarn add browsertype.js
$ bower install browsertype.js --saveCDN:
- https://bundle.run/[email protected]
- https://unpkg.com/[email protected]/main.js
- https://cdn.jsdelivr.net/npm/[email protected]
- https://cdn.jsdelivr.net/npm/[email protected]/main.min.js
- https://cdn.jsdelivr.net/gh/mcstreetguy/[email protected]/main.js
- https://cdn.jsdelivr.net/gh/mcstreetguy/[email protected]/main.min.js
Usage
Scripts
BrowserType.js registers a plain object in window, containing recognition expressions. It's structure is as following:
BrowserType = {
isOpera,
isFirefox,
isSafari,
isIE,
isEdge,
isChrome,
isBlink
}You can use these values directly in conditions:
if(BrowserType.isIE) {
alert('You got the worst browser around, congratulations.');
} else if(BrowserType.isChrome) {
alert('You got an evergreen browser, nice!');
}Stylesheets
BrowserType.js also sets a class on the html element, making it really easy to also differ between browsers in stylesheets.
bt-operabt-firefoxbt-safaribt-explorerbt-edgebt-chromebt-other
