Created
July 23, 2018 21:19
-
-
Save marioluevanos/f89655d79d97183e8c82c5306859b360 to your computer and use it in GitHub Desktop.
If a mobile device, return boolean
This file contains hidden or 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
const ifMobile = () => { | |
if( navigator.userAgent.match(/Android/i) || | |
navigator.userAgent.match(/webOS/i) || | |
navigator.userAgent.match(/iPhone/i) || | |
navigator.userAgent.match(/iPod/i) || | |
navigator.userAgent.match(/iPad/i) || | |
navigator.userAgent.match(/BlackBerry/i) || | |
navigator.userAgent.match(/IEMobile/i) || | |
navigator.userAgent.match(/Opera Mini/i) | |
) { | |
return navigator.userAgent | |
} | |
else return false | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment