Learn free online HTML5, javascript, and jquery Tutorials by Examples

Saturday 21 June 2014

How to detect Safari, Chrome, IE, Firefox and Opera browser | JavaScript

---------------------------------------------------
var isOpera = !!window.opera || navigator.userAgent.indexOf('Opera') >= 0;
var isFirefox = typeof InstallTrigger !== 'undefined';  
var isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0;

var isChrome = !!window.chrome;                         
var isIE = /*@cc_on!@*/false;                          

document.write('isFirefox: ' + isFirefox + '<br>');
document.write('isChrome: ' + isChrome + '<br>');
document.write('isSafari: ' + isSafari + '<br>');
document.write('isOpera: ' + isOpera + '<br>');
document.write('isIE: ' + isIE + '<br>');


--------------------------------------------------

No comments:

Post a Comment