Skip to content

Instantly share code, notes, and snippets.

@sathvikc
Created September 3, 2015 04:56
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 sathvikc/0f1ec90d366583347b17 to your computer and use it in GitHub Desktop.
Save sathvikc/0f1ec90d366583347b17 to your computer and use it in GitHub Desktop.
To detect Mobile browsers
<script language="javascript">
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)|| navigator.userAgent.match(/Opera Mini/i)) {
return true;
}
else {
return false;
}
}
if(detectmob()){
//Write your code here
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment