IT-Academy

JS Detekcia Prehliadaca

Jun 27th, 2016
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     var isOpera = !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0;
  2.     // Opera 8.0+ (UA detection to detect Blink/v8-powered Opera)
  3.     var isFirefox = typeof InstallTrigger !== 'undefined';   // Firefox 1.0+
  4.     var isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0;
  5.     // At least Safari 3+: "[object HTMLElementConstructor]"
  6.     var isChrome = !!window.chrome && !isOpera;              // Chrome 1+
  7.     var isIE = /*@cc_on!@*/false || !!document.documentMode;   // At least IE6
  8.  
  9.     var output = 'Detecting browsers by ducktyping:<hr>';
  10.     output += 'isFirefox: ' + isFirefox + '<br>';
  11.     output += 'isChrome: ' + isChrome + '<br>';
  12.     output += 'isSafari: ' + isSafari + '<br>';
  13.     output += 'isOpera: ' + isOpera + '<br>';
  14.     output += 'isIE: ' + isIE + '<br>';
  15.     document.body.innerHTML = output;
Advertisement
Add Comment
Please, Sign In to add comment