Skip to content

Instantly share code, notes, and snippets.

@adaniliuk
Created March 18, 2015 06:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adaniliuk/a2585d5527b0f528825f to your computer and use it in GitHub Desktop.
Save adaniliuk/a2585d5527b0f528825f to your computer and use it in GitHub Desktop.
Check if mobile from JavaScript
'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