IT-Academy

Browser JS

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