Created
March 18, 2015 06:35
-
-
Save dan-codes-16/a2585d5527b0f528825f to your computer and use it in GitHub Desktop.
Check if mobile from JavaScript
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
'use strict'; | |
module.exports = { | |
/** | |
* Checks for iOs, Android, Blackberry, Opera Mini, and Windows mobile devices | |
* Based on http://www.detectmobilebrowsers.com | |
* | |
* @return {Boolean} True if user agent is mobile | |
*/ | |
isMobile: function() { | |
var userAgent = navigator.userAgent || navigator.vendor || window.opera; | |
return (/iPhone|iPod|iPad|Silk|Android|BlackBerry|Opera Mini|IEMobile/).test(userAgent); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment