Created
November 8, 2020 06:32
-
-
Save Miciurash/fb256b93d0ca734dc991eac017c65b32 to your computer and use it in GitHub Desktop.
Detect browsers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Detect browsers | |
*/ | |
// Opera | |
var isOpera = | |
(navigator.userAgent.indexOf('Opera') || navigator.userAgent.indexOf('OPR')) != -1; | |
// Firefox | |
var isFirefox = navigator.userAgent.indexOf('Firefox') != -1; | |
// Safari | |
var isSafari = navigator.userAgent.indexOf('Safari') != -1; | |
// Internet Explorer 6-11 | |
var isIE = /*@cc_on!@*/ false || !!document.documentMode; | |
// Edge 20+ | |
var isEdge = !isIE && !!window.StyleMedia; | |
// Chrome | |
var isChrome = navigator.userAgent.indexOf('Chrome') != -1; | |
// Facebook or Instagram | |
var fbOrInstagram = | |
navigator.userAgent.indexOf('Instagram') != -1 || | |
(navigator.userAgent.match(/(iPod|iPhone|iPad)/) && | |
navigator.userAgent.match(/FBAV|FBBV|FBAN/i)); | |
//IE 9+ | |
var ie10AndBelow = navigator.userAgent.indexOf('MSIE') != -1; | |
var isIE10 = navigator.appVersion.indexOf('MSIE 10.') != -1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment