jsFiddle Demo
Look for the existence of touch
, if it is not present then you are more than likely dealing with a desktop:
edit: my original try/catch approach was apparently deprecated ( https://stackoverflow.com/a/4819886/1026459 )
$(document).ready(function() {
var isDesktop = (function() {
return !('ontouchstart' in window) // works on most browsers
|| !('onmsgesturechange' in window); // works on ie10
})();
//edit, if you want to use this variable outside of this closure, or later use this:
window.isDesktop = isDesktop;
if( isDesktop ){ /* desktop things */ }
});