Skip to content

Instantly share code, notes, and snippets.

@digdeep
Last active August 29, 2015 14:05
Show Gist options
  • Save digdeep/c622c528b3d71843675e to your computer and use it in GitHub Desktop.
Save digdeep/c622c528b3d71843675e to your computer and use it in GitHub Desktop.
isMobileTabletDesktop
if (navigator.userAgent.match(/Mobi/)) {
// mobile!
var windowWidth = window.screen.width < window.outerWidth ?
window.screen.width : window.outerWidth;
if(windowWidth < 683){
deviceType = 'mobile';
} else {
deviceType = 'tablet';
}
}
else if( navigator.userAgent.match(/iPad|Nexus|Tablet/i) ){
deviceType = 'tablet';
}
else {
deviceType = 'desktop'
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment