Skip to content

Instantly share code, notes, and snippets.

@zhenyanghua
Created May 5, 2015 15:09
Show Gist options
  • Save zhenyanghua/aeeef2aff02fd1928e5c to your computer and use it in GitHub Desktop.
Save zhenyanghua/aeeef2aff02fd1928e5c to your computer and use it in GitHub Desktop.
Detecting a mobile browser
function detectmob() {
if( navigator.userAgent.match(/Android/i)
|| navigator.userAgent.match(/webOS/i)
|| navigator.userAgent.match(/iPhone/i)
|| navigator.userAgent.match(/iPad/i)
|| navigator.userAgent.match(/iPod/i)
|| navigator.userAgent.match(/BlackBerry/i)
|| navigator.userAgent.match(/Windows Phone/i)
){
return true;
}
else {
return false;
}
}
@zhenyanghua
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment