Permalink
Browse files

Merge branch 'master' of github.com:Modernizr/Modernizr

  • Loading branch information...
2 parents a3de7ff + b9d9e0f commit c53a0732ee277e15a6feaa9029d01c1095a4f2b3 @paulirish paulirish committed Sep 30, 2010
Showing with 68 additions and 0 deletions.
  1. +68 −0 touch.html
View
@@ -0,0 +1,68 @@
+<!DOCTYPE html>
+<html lang="en" dir="ltr" id="modernizr-touch-tests" class="no-js">
+<head>
+ <meta charset="utf-8">
+ <title>Modernizr: Touch tests</title>
+</head>
+
+<body>
+
+ <h1>Modernizr Touch tests</h1>
+ <p>This page tests various approaches to detecting Touch events / touch support in the browser. Please visit this test page with any touch devices you have and submit the results, so that we may include a reliable Modernizr.touch test in our next major release!</p>
+
+ <table>
+ <thead>
+ <th>'ontouchstart' in window</th>
+ <th>try/catch {<br>
+&nbsp;&nbsp;&nbsp;document.createEvent("TouchEvent");<br>
+}</th>
+ <th>'createTouch' in document</th>
+ <th>typeof TouchEvent != "undefined"</th>
+ <th>typeof Touch == "object"</th>
+ </thead>
+ <tbody>
+ <td id="ontouchstart_in_window"></td>
+ <td id="try_doc_createevent"></td>
+ <td id="createtouch_in_doc"></td>
+ <td id="typeof_touch_not_undefined"></td>
+ <td id="typeof_touch_object"></td>
+ </tbody>
+ </table>
+<script>
+var try_catch, k;
+try {
+ document.createEvent("TouchEvent");
+ try_catch = 1;
+} catch (e) {
+ try_catch = 0;
+}
+
+var _bTestResults = {
+ 'ontouchstart_in_window': (!!('ontouchstart' in window) ? 1 : 0),
+ 'try_doc_createevent': try_catch,
+ 'createtouch_in_doc': (!!('createTouch' in document) ? 1 : 0),
+ 'typeof_touch_not_undefined': (!!(typeof TouchEvent != "undefined") ? 1 : 0),
+ 'typeof_touch_object': (!!(typeof Touch == "object") ? 1 : 0)
+};
+
+
+for (k in _bTestResults) {
+ document.getElementById(k).innerHTML = (!!(_bTestResults[k]) ? 'Yes' : 'No');
+}
+
+// Beacon the results to Browserscope.
+(function() {
+ var _bTestKey = 'agt1YS1wcm9maWxlcnINCxIEVGVzdBjGxLICDA';
+ var _bScript = document.createElement('script');
+ _bScript.src = 'http://www.browserscope.org/user/beacon/' + _bTestKey;
+ _bScript.setAttribute('async', 'true');
+ var scripts = document.getElementsByTagName('script');
+ var lastScript = scripts[scripts.length - 1];
+ lastScript.parentNode.insertBefore(_bScript, lastScript);
+})();
+</script>
+
+<p>Thanks!</p>
+
+</body>
+</html>

0 comments on commit c53a073

Please sign in to comment.