JAVASCRIPT   68

browser.js

Guest on 30th July 2021 02:46:54 PM

  1. const Browser = {
  2.   // Firefox 1.0+
  3.   isFirefox: () => {
  4.     return typeof InstallTrigger !== 'undefined'
  5.   },
  6.   // Internet Explorer 6-11
  7.   isIE: () => {
  8.     return navigator.userAgent.indexOf('MSIE') !== -1 || !!document.documentMode
  9.   },
  10.   // Edge 20+
  11.   isEdge: () => {
  12.     return !Browser.isIE() && !!window.StyleMedia
  13.   },
  14.   // Chrome 1+
  15.   isChrome: () => {
  16.     return !!window.chrome && !!window.chrome.webstore
  17.   },
  18.   // At least Safari 3+: "[object HTMLElementConstructor]"
  19.   isSafari: () => {
  20.     return Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0 ||
  21.         navigator.userAgent.toLowerCase().indexOf('safari') !== -1
  22.   }
  23. }
  24.  
  25. export default Browser

Raw Paste


Login or Register to edit or fork this paste. It's free.