JS

HOW TO DETECT BROWSER WITH JAVASCRIPT

CHROME if (navigator.userAgent.indexOf("Chrome")  != -1 ) { console.log("Chrome"); }   FIREFOX if (navigator.userAgent.indexOf("Firefox") != -1 ) { console.log("Firefox"); }

READ THE USER AGENT

01

EDGE if (navigator.userAgent.indexOf("Edge") != -1 ) { console.log("Edge");    SAFARI if (navigator.userAgent.indexOf("Safari") != -1 ) { console.log("Safari");

PARSE USER AGENT var result = bowser.getParser (navigator.userAgent).getResult();   BROWSER INFO console.log(result.browser.name); console.log(result.browser.version); console.log(result.engine);

USE DETECTION LIBRARY

02

MOZ - FIREFOX WEBKIT - CHROME, SAFARI, OPERA, EDGE MS - OLD INTERNET EXPLORER & EDGE O - OLD OPERA var prefix = (Array.prototype.slice.call (window.getComputedStyle (document.documentElement, ''))      .join('')   .match(/-(moz|webkit|ms)-/))[1];

DETECT CSS PREFIX

03

var opera = (!!window.opr && !!opr.addons) || !!window.opera || navigator.userAgent. indexOf(' OPR/') >= 0; var isFirefox = typeof InstallTrigger !== 'undefined'; var isIE = /*@cc_on!@*/false || !!document.documentMode; var isEdge = !isIE && !!window.StyleMedia; var isChrome = !!window.chrome;  var isBlink = (isChrome || isOpera) && !!window.CSS;

DUCK  TYPING

04