Browserizr is tiny library, that detects your browser and platform,
with testingwindow.navigator.userAgent
andwindow.navigator.platform
.
https://wezomagency.github.io/browserizr/
Table of contents
$ npm i browserizr
<script src="https://unpkg.com/browserizr@latest/dist/browserizr.js"></script>
<!-- or minimized version -->
<script src="https://unpkg.com/browserizr@latest/dist/browserizr.min.js"></script>
import Browserizr from 'browserizr'
<script src="your/path/to/browserizr.js"></script>
<!-- will be added to Window, as global object Browserizr -->
please read:
Browserizr has detects test for:
Browserizr.detect().isAndroid()
Browserizr.detect().isAndroid3()
Browserizr.detect().isAndroid4()
Browserizr.detect().isAndroid5()
Browserizr.detect().isAndroid6()
Browserizr.detect().isAndroid7()
Browserizr.detect().isAndroid8()
Browserizr.detect().isBlackberry()
Browserizr.detect().isBlackberry10()
Browserizr.detect().isChrome()
Browserizr.detect().isDesktop()
Browserizr.detect().isEdge()
Browserizr.detect().isEdgeAndroid()
Browserizr.detect().isEdgeIOS()
Browserizr.detect().isIE()
Browserizr.detect().isIE8()
Browserizr.detect().isIE9()
Browserizr.detect().isIE10()
Browserizr.detect().isIE11()
Browserizr.detect().isIOS()
Browserizr.detect().isIPad()
Browserizr.detect().isIPod()
Browserizr.detect().isIPhone()
Browserizr.detect().isIPhone4()
Browserizr.detect().isIPhone5()
Browserizr.detect().isIPhone678()
- iPhone 6/7/8Browserizr.detect().isIPhone678plus()
- iPhone 6/7/8 plusBrowserizr.detect().isIPhonex()
Browserizr.detect().isLinux()
Browserizr.detect().isMac()
Browserizr.detect().isMacLike()
Browserizr.detect().isMeizuPhone()
Browserizr.detect().isMeizunotePhone()
Browserizr.detect().isMobile()
Browserizr.detect().isMoz()
Browserizr.detect().isOpera()
Browserizr.detect().isRedmiPhone()
Browserizr.detect().isRedminotePhone()
Browserizr.detect().isSafari()
Browserizr.detect().isWindows()
Browserizr.detect().isWindows_xp()
Browserizr.detect().isWindows_vista()
Browserizr.detect().isWindows7()
Browserizr.detect().isWindows8()
Browserizr.detect().isWindows10()
Browserizr.detect().isWindowsPhone()
// you can use shorthand way
const browser = Browserizr.detect();
if (browser.isChrome()) {
// ....
}
Create array with CSS classes
Parameters:
Name | Data type | Default value | Description |
---|---|---|---|
tests |
string[] |
array of wanted tests, each name - test name without is prefix |
|
cssPrefix |
string |
"" |
custom prefix for CSS class name |
Usage examples:
const classes = Browserizr.detect().cssClasses(['Mobile', 'Desktop']);
// => ['is-mobile', 'is-not-desktop'] => if mobile device
// => ['is-not-mobile', 'is-desktop'] => if desktop
const classes = Browserizr.detect().cssClasses(['Mobile', 'Desktop'], 'browserizr-');
// => ['browserizr-is-mobile', 'browserizr-is-not-desktop'] => if mobile device
// => ['browserizr-is-not-mobile', 'browserizr-is-desktop'] => if desktop
default value: 'is-'
Browserizr.detect().cssClasses(['Android']) // => 'is-android' <- default prefix
Browserizr.prefixIs = ''; // set empty
Browserizr.detect().cssClasses(['Android']) // => 'android'
Browserizr.prefixIs = 'that-is-my-'; // ;)
Browserizr.detect().cssClasses(['Android']) // => 'that-is-my-android'
default value: 'is-not-'
Browserizr.detect().cssClasses(['Android']) // => 'is-not-android' <- default prefix
Browserizr.prefixIs = 'no-'; // set custom
Browserizr.detect().cssClasses(['Android']) // => 'no-android'
Browserizr.prefixIs = 'that-is-not-my-'; // ;)
Browserizr.detect().cssClasses(['Android']) // => 'that-is-not-my-android'