Skip to content

Instantly share code, notes, and snippets.

@CyberSliver
Created November 18, 2013 10:26
Show Gist options
  • Save CyberSliver/7525673 to your computer and use it in GitHub Desktop.
Save CyberSliver/7525673 to your computer and use it in GitHub Desktop.
Test Touch support.
<!DOCTYPE html>
<html><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title> - jsFiddle demo by CyberSliver</title>
<script type="text/javascript" src="//code.jquery.com/jquery-2.0.2.js"></script>
<link rel="stylesheet" type="text/css" href="/css/result-light.css">
<style type="text/css">
</style>
<script type="text/javascript">//<![CDATA[
$(window).load(function(){
$(function(){
if (typeof document.documentElement.ontouchstart != 'undefined' || typeof navigator.msMaxTouchPoints != 'undefined') {
$('#touchValue')[0].innerHTML = 'True';
} else {
$('#touchValue')[0].innerHTML = 'False';
}
});
});//]]>
</script>
</head><script type="text/javascript">var new_nav = new function() {};var x;var old_navigator = window.navigator;for (x in navigator) {if (typeof navigator[x] == 'function') {eval("new_nav." + x + " = function() { return old_navigator." + x + "();};");} else {eval("new_nav." + x + " = navigator." + x + ";");}}new_nav.userAgent = "Mozilla/5.0 (Linux; Android 4.1.1; Nexus 7 Build/JRO03D) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Safari/535.19";new_nav.vendor = "";window.navigator = new_nav;</script>
<body style="">
<div>
Touch: <span id="touchValue">False</span>
</div>
</body></html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment