Like yoav barneaThe best must be :
var isMobile = (/Mobile/i.test(navigator.userAgent)); But like like Yoav Barnea says, but updated...
// Seem legit var mobileisMobile = ('DeviceOrientationEvent' in window || 'orientation' in window); // MyBut Chromewith desktopmy onChrome windowon havewindows, DeviceOrientationEvent == fct() if (/Windows NT|Macintosh|LinuxNT|Macintosh|Mac OS X|Linux/i.test(navigator.userAgent)) mobileisMobile = false; // My android have "linux" too if (/Mobile/i.test(navigator.userAgent)) isMobile = true; After this 3 tests, i hope var isMobile is... ok