Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

browser detection

// Opera 8.0+
var isOpera = (!!window.opr && !!opr.addons) || !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0;

// Firefox 1.0+
var isFirefox = typeof InstallTrigger !== 'undefined';

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

// Internet Explorer 6-11
var isIE = /*@cc_on!@*/false || !!document.documentMode;

// Edge 20+
var isEdge = !isIE && !!window.StyleMedia;

// Chrome 1 - 79
var isChrome = !!window.chrome && (!!window.chrome.webstore || !!window.chrome.runtime);

// Edge (based on chromium) detection
var isEdgeChromium = isChrome && (navigator.userAgent.indexOf("Edg") != -1);

// Blink engine detection
var isBlink = (isChrome || isOpera) && !!window.CSS;


var output = 'Detecting browsers by ducktyping:<hr>';
output += 'isFirefox: ' + isFirefox + '<br>';
output += 'isChrome: ' + isChrome + '<br>';
output += 'isSafari: ' + isSafari + '<br>';
output += 'isOpera: ' + isOpera + '<br>';
output += 'isIE: ' + isIE + '<br>';
output += 'isEdge: ' + isEdge + '<br>';
output += 'isEdgeChromium: ' + isEdgeChromium + '<br>';
output += 'isBlink: ' + isBlink + '<br>';
document.body.innerHTML = output;
 Run code snippet
Comment

PREVIOUS NEXT
Code Example
Javascript :: node powershell 
Javascript :: framer motion nextjs 
Javascript :: javascript round .5 down 
Javascript :: play notification sound on chat js 
Javascript :: animate javascript 
Javascript :: push to object javascript 
Javascript :: An invalid form control with ... is not focusable. 
Javascript :: js scroll to bottom exact 
Javascript :: react native debugger 
Javascript :: check url if it has trailing slash 
Javascript :: bookmarklets 
Javascript :: web3 get network name 
Javascript :: convert string to integer in javascript 
Javascript :: annotation 
Javascript :: create javascript array with 1 value 
Javascript :: what is redis 
Javascript :: url encoded body in node.js 
Javascript :: multiple if statements js es6 inline 
Javascript :: fs.appendFileSync in nodejs 
Javascript :: javascript remove last charter stings 
Javascript :: remove javascript 
Javascript :: convert int to string in angular 
Javascript :: jquery if else 
Javascript :: upload image to server next js 
Javascript :: different uniqid usage 
Javascript :: Uncaught TypeError: Data.filter is not a function 
Javascript :: debounce function in javascript 
Javascript :: kick members node js 
Javascript :: queryselector in javascript 
Javascript :: add a socket to a room in socket.io 
ADD CONTENT
Topic
Content
Source link
Name
7+4 =