Last active
September 2, 2015 13:14
-
-
Save armand1m/a719ab6e80e62c2e68bb to your computer and use it in GitHub Desktop.
Verifica se o navegador está usando um User Agent que o identifique como dispositivo mobile.
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
/** | |
* Verifica se o navegador está usando um User Agent que o identifique | |
* como dispositivo mobile. | |
* | |
* @return bool | |
* @author Armando Magalhães | |
*/ | |
function hasMobileUserAgent() { | |
return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/.test(navigator.userAgent); | |
} | |
/** | |
* Verifica se é um navegador mobile. | |
* | |
* @return bool | |
* @author Armando Magalhães | |
*/ | |
function isMobile() { | |
return hasMobileUserAgent() && window.matchMedia("(max-width: 640px)").matches; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment