Skip to content

Instantly share code, notes, and snippets.

@Donmclean
Last active January 10, 2017 20:11
Show Gist options
  • Save Donmclean/3e872ef5b18bea4814665736d747aa54 to your computer and use it in GitHub Desktop.
Save Donmclean/3e872ef5b18bea4814665736d747aa54 to your computer and use it in GitHub Desktop.
Detects via javascript is client is mobile/tablet regardless of size. Will always return false on desktop browser. Very Useful!
const isTabletOrMobileDevice = () => {
// return window.screenX === 0 || window.screenLeft === 0; //OLD
return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(window.navigator.userAgent);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment