3.0.0 • Published 7 years ago

bobr-js v3.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

BOBR.js - Bad Outdated Browser Reminder

Simply tool for detects outdated browsers. Test CSS properties support or run you custom tests.

Example

Usage

Download using NPM

$ npm install tabit --save

Import and call

import Bobr from 'bobr-js'

Bobr({
  test: 'ie10',
  callback: function (passed) {
    if (!passed) {
      alert('You are using an outdated browser! The site may not be displayed correctly. You need to upgrade your browser.');
    }
  }
});

...or manually download and inject the minified script into your website.

Be sure that you build works in target browser. For example Webpack has problem with IE 8.

Options

  • test - (string|function|array) string with css property for test, or function (must return true or false), or array of it.
  • callback - (function) callback after tests done

For test option aliases available: ie8, ie9, ie10, ie11 (detect if less then). You can set css properties in camel case (boxSizing) or like in css (box-sizing).

Examples

Detect IE 10+ and localstorage support with Modernizr

Bobr({
  test: [
    'ie10',
    function() {
      if (!Modernizr) return true;
      return Modernizr.localstorage;
    }
  ],
  callback: function (passed) {
    if (!passed) {
      alert('You are using an outdated browser! The site may not be displayed correctly. You need to upgrade your browser.');
    }
  }
});

Redirect ie8 users in special page

Bobr({
  test: 'ie9',
  callback: function (passed) {
    if (!passed) {
       document.location = 'bad-browser.html';
    }
  }
});

License

The MIT License

Copyright (c) 2017 Andrey Hohlov