The Wayback Machine - https://web.archive.org/web/20240618011716/https://www.geeksforgeeks.org/how-to-check-the-user-is-using-internet-explorer-in-javascript/
Open In App

How to check the user is using Internet Explorer in JavaScript?

Last Updated : 14 May, 2019
Improve
Improve
Like Article
Like
Save
Share
Report

There may arise cases when we need to check the browser being used. Some features of your website may not be supported in older browsers like Internet Explorer(IE). There are different ways to check the version of Internet Explorer being used.

Syntax-1: For Internet Explorer 10 or older

var ua = window.navigator.userAgent;
var msie = ua.indexOf('MSIE ');
if (msie > 0) {
   // IE 10 or older => return version number
        return parseInt(ua.substring(msie + 5, ua.indexOf('.', msie)), 10);
    }

Syntax-2: For Internet Explorer 11

var ua = window.navigator.userAgent;
var trident = ua.indexOf('Trident/');
if (trident > 0) {
        // IE 11 => return version number
        var rv = ua.indexOf('rv:');
        return parseInt(ua.substring(rv + 3, ua.indexOf('.', rv)), 10);
    }

Syntax-3: For Internet Explorer 12+ (Edge)

var ua = window.navigator.userAgent;
var edge = ua.indexOf('Edge/');
if (edge > 0) {
       // Edge (IE 12+) => return version number
       return parseInt(ua.substring(edge + 5, ua.indexOf('.', edge)), 10);
    }

Example:




<!DOCTYPE html>
<html>
  
<head>
    <title>
      Detects user uses Internet Explorer
  </title>
</head>
  
<body>
    <center>
        <h1 style="color:green">GeeksforGeeks</h1>
        <script>
            //detects if user uses Internet Explorer
            //returns version of IE or false, if browser is not IE
            //Function to detect IE or not
            function IEdetection() {
                var ua = window.navigator.userAgent;
                var msie = ua.indexOf('MSIE ');
                if (msie > 0) {
                    // IE 10 or older, return version number
                    return ('IE ' + parseInt(ua.substring(
                      msie + 5, ua.indexOf('.', msie)), 10));
                }
                var trident = ua.indexOf('Trident/');
                if (trident > 0) {
                    // IE 11, return version number
                    var rv = ua.indexOf('rv:');
                    return ('IE ' + parseInt(ua.substring(
                      rv + 3, ua.indexOf('.', rv)), 10));
                }
                var edge = ua.indexOf('Edge/');
                if (edge > 0) {
                    //Edge (IE 12+), return version number
                    return ('IE ' + parseInt(ua.substring(
                      edge + 5, ua.indexOf('.', edge)), 10));
                }
                // User uses other browser
                return ('Not IE');
            }
            var result = IEdetection();
            document.write(result);
        </script>
    </center>
</body>
  
</html>


Output (Opening with Firefox):

Not IE

Output (Opening with IE 11):

IE 11

Output (Opening with Edge):

IE 18


Similar Reads

Which version of Internet Explorer was the first to native support HTML5 elements ?
Internet Explorer was Microsoft's first browser service which was launched as an add-on package with windows-95 and it had various advantages, but with advancement in technology and development of HTML-5 in 2008, the earlier versions failed to render services, such as video streaming working without flash or plug-ins. Most of the browsers of that t
2 min read
Create File Explorer App using React-Native
Creating a File Explorer app using React Native provides a seamless way to explore and interact with the device's file system on both iOS and Android platforms. In this tutorial, we'll guide you through the process of building a simple yet functional File Explorer app. Output Preview: Prerequisites:Node.js and npm installedReact Native CLI installe
3 min read
User to User private Chat App using ReactJS and Firebase | Without socket programming
This article covers how to make a User to User private Chat App using React JS and Firebase (without socket programming). React is a JavaScript framework provided by Facebook and is used to build fully-featured web applications. We will be following the below steps for creating our application: npx create-react-app chat-appcd chat-app Now install a
10 min read
How to detect the Internet connection is offline or not using JavaScript?
In some cases, it is necessary to determine whether the browser is online or offline before performing a required task. Many developers use AJAX to determine the connection status of the browser (online or offline) by sending a request to the server. However, this is not a good method for determining the state of the browser because it requires ban
1 min read
How to check user authentication in GET method using Node.js ?
There are so many authentication methods like web token authentication, cookies based authentication, and many more. In this article, we will discuss one of the simplest authentication methods using express.js during handling clients get a request in node.js with the help of the HTTP headers. Approach: HTTP protocols used various types of headers f
3 min read
How to get a dialog box if there is no internet connection using jQuery ?
In this article, we will see how to check the internet connection using jQuery. We will be using navigator.onLine which will return true if an internet connection is available otherwise it will return false. Syntax: navigator.onLine Returns: True: If the internet connection is available.False: If the internet connection is not available. Example 1:
2 min read
How to test internet speed using Node.js ?
The following approach covers how to do an internet speed test in NodeJs. We will use the speed-test node-package to achieve so. This package will help us for getting the current download and upload speed. Use the following steps to install the module and do a speed test in node.js: Step 1: Creating a directory for our project and making that our w
3 min read
Detect the Operating System of User using JavaScript
The task is detect the operating system of User with the help of JavaScript. we're going to discuss few techniques. Approach: Access the navigator.appVersion or navigator.userAgent property. Get the index of the OS using indexOf() method. If index is other than -1, then it is the OS, that we are looking for. Example 1: In this example, navigator.ap
2 min read
How to display hidden element when a user starts typing using JavaScript ?
Method 1: Using the oninput attribute to input element: The oninput attribute is fired whenever user starts typing to the input element. This can be used to detect changes in a &lt;input&gt; or &lt;textarea&gt; element. A function is called with the value of this attribute. This function selects the hidden element and changes its display property t
3 min read
How to detect the user browser ( Safari, Chrome, IE, Firefox and Opera ) using JavaScript ?
The browser on which the current page is opening can be checked using JavaScript. The userAgent property of the navigator object is used to return the user-agent header string sent by the browser. This user-agent string contains information about the browser by including certain keywords that may be tested for their presence. The presence of a spec
4 min read