If you wanna know your browser name/type using JavaScript. You can refer below function:

var knowYourBrowser = (function() {
   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);
   }

   // Opera Browser => Return op static word
   var isOpera = navigator.userAgent.match(/Opera|OPR\//);
   if(isOpera) {
       return 'opera';
   }
   // Chrome 1+
   var isChrome = !!window.chrome && !!window.chrome.webstore;
   if(isChrome) {
       return 'chrome';
   }

   // Safari 3.0+ "[object HTMLElementConstructor]"
   var isSafari = /constructor/i.test(window.HTMLElement) || (function (p) { return p.toString() === "[object SafariRemoteNotification]"; })(!window['safari'] || (typeof safari !== 'undefined' && safari.pushNotification));
   if(isSafari) {
       return 'safari';
   }

   // Firefox 1.0+
   var isFirefox = typeof InstallTrigger !== 'undefined';
   if(isFirefox) {
       return 'firefox';
   }

   // other browser
   return false;

})();


//Updated by Sajjan Singh

Talk to an Expert

Do you have any questions? Please do not hesitate to contact us directly. Our team will come back to you within a matter of hours to help you.

Insights


Related articles

Angular JS
Angular JS

October 28, 2019