Created
October 31, 2016 10:24
-
-
Save magician11/b0542cd51d9ee31034afa19e3bb719e1 to your computer and use it in GitHub Desktop.
Testing for touch screen devices
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<title>Touchscreen Test</title> | |
<style> | |
body { | |
text-align: center; | |
} | |
</style> | |
</head> | |
<body> | |
<h1>Touch Screen Test</h1> | |
<p>Result: <span class="result"></span></p> | |
<script src="https://code.jquery.com/jquery-3.1.1.min.js" integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" crossorigin="anonymous"></script> | |
<script> | |
// Touch Device Detection | |
var isTouchDevice = 'ontouchstart' in document.documentElement; | |
var response = isTouchDevice ? 'This is a touchscreen' : 'This is not a touchscreen'; | |
$('.result').text(response); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Live demo http://apps.golightlyplus.com/touch-test/