This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

check-ie
TypeScript icon, indicating that this package has built-in type declarations

2.0.1 • Public • Published

check-ie

A lightweight, zero-dependency way to check if a user browser is Internet Explorer.

This module checks if a user browser is Internet Explorer based on the user agent string (In browser context window.navigator.userAgent).

Note: User agents can easily be spoofed. You should always rely on checking for existence of JavaScript features for being completely sure of support for them and the browser being used. See the MDN disclaimer on user agent string accuracy for more details.

Usage

This module is very easy to use. Simply pass in a user agent string and get a result object in return.

const checkIE = require('check-ie')
 
const ie11 = 'Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko'
 
checkIE(ie11) // { isIE: true, name: 'Internet Explorer', version: '11.0' }
 
const firefox = 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:64.0) Gecko/20100101 Firefox/64.0'
 
checkIE(firefox) // { isIE: false, name: '', version: '' }

Options

Per default, this module will check for all Internet Explorer versions including Edge if no options are passed.

checkIE(window.navigator.userAgent)

You may restrict what versions are detected like so:

// Note: ie10 includes all versions including 10 and below
 
const options = {
  ie10: true,
  ie11: true,
  edge: false // Detects Internet Explorer, but not Edge
}
 
checkIE(window.navigator.userAgent)

Omitting a value counts as omission of detection, i.e. omitting ie10 would be equivalent to setting ie10 to false.

For example, if you only want to detect IE 11 and below, your options setup would look like this:

const options = {
  ie10: true,
  ie11: true
}

License

MIT © Linus Willner and Curtis Fowler.

Package Sidebar

Install

npm i check-ie

Weekly Downloads

31

Version

2.0.1

License

MIT

Unpacked Size

13 kB

Total Files

16

Last publish

Collaborators

  • linuswillner