Browser Check

by Devlin Pajaron

HTML

Browser: <span id="browserName"></span>

<hr>
Working in the following versions:
<ul>
Opera - 58.0.3135.79<br/>
Firefox - 65.0.2 (64-bit)<br/>
Safari - 10.1.2 (I have no safari so I can't verify this)<br/>
IE - 11.413.15063 (JS Fiddle no longer supports IE just paste in Console)<br/>
Edge - 44.17763.1.0<br/>
Chrome - 72.0.3626.121 (Official Build) (64-bit)
</ul>
<h2>Last update: 06-March-2019</h2>

JavaScript

function name() {
  var browserName = '';
  var userAgent = navigator.userAgent;
  (typeof InstallTrigger !== 'undefined') && (browserName = 'Firefox');
  ( /* @cc_on!@*/ false || !!document.documentMode) && (browserName = 'IE');
  (!!window.chrome && userAgent.match(/OPR/)) && (browserName = 'Opera');
  (!!window.chrome && userAgent.match(/Edge/)) && (browserName = 'Edge');
  (!!window.chrome && !userAgent.match(/(OPR|Edge)/)) && (browserName = 'Chrome');

  /**
   * Expected returns
   * Firefox, Opera, Edge, Chrome
   */
  return browserName;
}

var elem = document.getElementById('browserName');
elem.innerHTML = name();