1// Opera 8.0+
2var isOpera = (!!window.opr && !!opr.addons) || !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0;
3
4// Firefox 1.0+
5var isFirefox = typeof InstallTrigger !== 'undefined';
6
7// Safari 3.0+ "[object HTMLElementConstructor]"
8var isSafari = /constructor/i.test(window.HTMLElement) || (function (p) { return p.toString() === "[object SafariRemoteNotification]"; })(!window['safari'] || (typeof safari !== 'undefined' && window['safari'].pushNotification));
9
10// Internet Explorer 6-11
11var isIE = /*@cc_on!@*/false || !!document.documentMode;
12
13// Edge 20+
14var isEdge = !isIE && !!window.StyleMedia;
15
16// Chrome 1 - 79
17var isChrome = !!window.chrome && (!!window.chrome.webstore || !!window.chrome.runtime);
18
19// Edge (based on chromium) detection
20var isEdgeChromium = isChrome && (navigator.userAgent.indexOf("Edg") != -1);
21
22// Blink engine detection
23var isBlink = (isChrome || isOpera) && !!window.CSS;
24
25
26var output = 'Detecting browsers by ducktyping:<hr>';
27output += 'isFirefox: ' + isFirefox + '<br>';
28output += 'isChrome: ' + isChrome + '<br>';
29output += 'isSafari: ' + isSafari + '<br>';
30output += 'isOpera: ' + isOpera + '<br>';
31output += 'isIE: ' + isIE + '<br>';
32output += 'isEdge: ' + isEdge + '<br>';
33output += 'isEdgeChromium: ' + isEdgeChromium + '<br>';
34output += 'isBlink: ' + isBlink + '<br>';
35document.body.innerHTML = output;
36
37// ref https://stackoverflow.com/questions/9847580/how-to-detect-safari-chrome-ie-firefox-and-opera-browser