Last active
October 17, 2016 13:22
-
-
Save ingozoell/8ca8731362407ba677589ffa791ea89f to your computer and use it in GitHub Desktop.
Touch Device Detection
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var checkTouch = function(){ | |
/* Touch Device Detection */ | |
var isTouchDevice = 'ontouchstart' in document.documentElement; | |
var isTouchDeviceFireFoxBug = navigator.userAgent.toLowerCase().indexOf('firefox') > -1; /* Fixed FireFox Bug */ | |
var isTouch = isTouchDevice || isTouchDeviceFireFoxBug; | |
if( isTouch ) { | |
$('html').addClass('touch'); | |
} else { | |
$('html').addClass('no-touch'); | |
} | |
}; | |
checkTouch(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment