Created
July 23, 2012 18:27
-
-
Save brianium/3165240 to your computer and use it in GitHub Desktop.
is_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
function isMobileDevice() | |
{ | |
var agent = navigator.userAgent.toLowerCase(); | |
var otherBrowser = (agent.indexOf("series60") != -1) || (agent.indexOf("symbian") != -1) || (agent.indexOf("windows ce") != -1) || (agent.indexOf("blackberry") != -1); | |
var mobileOS = typeof orientation != 'undefined' ? true : false; | |
var touchOS = ('ontouchstart' in document.documentElement) ? true : false; | |
var iOS = (navigator.platform.indexOf("iPhone") != -1) || | |
(navigator.platform.indexOf("iPad") != -1) ? true : false; | |
var android = (agent.indexOf("android") != -1) || (!iOS && !otherBrowser && touchOS && mobileOS) ? true : false; | |
if ( otherBrowser || mobileOS || touchOS || iOS || android ) return true; | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment