JavaScript to recognize Browser

Hello,

I would like to stop users from being able to fill out a public form with Internet Explorer. Is there a JavaScript that I could use to determine browser being used?

Thanks,

Alberto

Dear @adasilva,
Please, try the following code:

/* Sample function that returns boolean in case the browser is Internet Explorer*/
function isIE() {
  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()){
    alert('It is InternetExplorer');
}else{
    alert('It is NOT InternetExplorer');
}

Code by Alvaro Aneiros from https://jsfiddle.net/alvaroAV/svvz7tkn/

2 Likes