Detect Internet Explorer and display a warning message to change the browser

Detect Internet Explorer and display a warning message to change the browser

As you all know that Microsoft has ended the support for the Internet Explorer browser. Modern web technologies are also not supporting it. In this article, we will see how to Detect Internet Explorer using JavaScript. We will also display a warning message to change the browser.

The Problem

You may have seen the website which says that they are not supported by the IE browser. Is there a way to Detect Internet Explorer? e.g. one of the most popular websites for JavaScript developers is jsfiddle.net. When you open it in Internet Explorer you will see the following warning:

Fiddle-is-not-supported-on-Internet-Explorer
This image was taken in February 2020

You may want to create a website in the latest technology stack that works perfectly in all browsers. But when you open it on Internet Explorer you shout “What a holy shit! The site is not working at all”. The problem is with the Internet Explorer which Microsoft has ended its support.

The Microsoft Security Chief says that the Internet Explorer is not a browser.

How you may detect which browser it is? Detect Internet Explorer

There are many different ways for detecting the browser. Nowadays, you can also detect the platform device and the operating system installed on it using both PHP and JavaScript.

In the following code, we will detect the browser using simple JavaScript code. It will tell whether the user is using Internet Explorer or not.

<script type='text/javascript'>
	function isItIE() {
	  user_agent = navigator.userAgent;
	  var is_it_ie = user_agent.indexOf("MSIE ") > -1 || user_agent.indexOf("Trident/") > -1;
	  return is_it_ie; 
	}

	if (isItIE()){
	    console.log('It is Internet Explorer');
	} else{
	    console.log('It is not Internet Explorer');
	}
</script>

This is a standalone code and does not require jQuery or any other JavaScript library to involve.

Using this code you can detect the browser and can display an alert message to change the browser.

More to read

Related Posts