Created
April 28, 2010 00:05
-
-
Save dperini/381530 to your computer and use it in GitHub Desktop.
This file contains 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
<html> | |
<head> | |
<title>TouchEvent detection for iPhone/iPod/iPad</title> | |
<script type="text/javascript"> | |
var isTouch = (function() { | |
var event, feature = false, | |
support = function() { feature = true; }, | |
element = document.createElement('div'); | |
try { | |
event = document.createEvent('TouchEvent'), | |
event.initTouchEvent('touchstart', true, true, document.defaultView); | |
element.addEventListener('touchstart', support, false); | |
element.dispatchEvent(event); | |
} catch(e) { | |
feature = false; | |
} | |
return feature; | |
})(); | |
alert(isTouch); | |
</script> | |
</head> | |
<body> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment