Check if browser is Internet Explorer

Sample javascipt function to check if browser is internet explorer

HTML

<h1 id="myHeader"></h1>

CSS

#myHeader {
  background-color: lightblue;
  color: black;
  padding: 40px;
  text-align: center;
}

JavaScript

function isIE() {

 var number ='my Header'
  ua = navigator.userAgent;
  /* MSIE used to detect old browsers and Trident used to newer ones*/
  var is_ie = ua.indexOf("MSIE ") > -1 || ua.indexOf("Trident/") > -1;
  
 
  return is_ie; 
}
/* Create an alert to show if the browser is IE or not */
if (isIE()){
 document.getElementById("myHeader").innerHTML = "Hello!!!";
     
}else{
alert('is not ie');
 }