Launch Week Day 2: Introducing Reports: An Extensible Reporting Framework for Socket Data.Learn More
Socket
Book a DemoSign in
Socket

check-ie

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

check-ie

Check if user browser is Internet Explorer.

latest
Source
npmnpm
Version
2.0.1
Version published
Weekly downloads
418
-19.77%
Maintainers
1
Weekly downloads
 
Created
Source

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.

Keywords

internet explorer

FAQs

Package last updated on 28 May 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts