Piece of browser detection code from prototype.js - Node.js Environment

Node.js examples for Environment:Browser

Description

Piece of browser detection code from prototype.js

Demo Code



// piece of browser detection code from prototype.js
chem.isOpera = Object.prototype.toString.call(window.opera) == '[object Opera]';
chem.isIE = !!window.attachEvent && !chem.isOpera;
chem.isWebKit = navigator.userAgent.indexOf('AppleWebKit/') > -1;
chem.isGecko = navigator.userAgent.indexOf('Gecko') > -1 && navigator.userAgent.indexOf('KHTML') === -1;
chem.isMobileSafari = /Apple.*Mobile.*Safari/.test(navigator.userAgent);

Related Tutorials