touch.html (1598B)
1 <html> 2 <head> 3 <meta charset="utf-8" /> 4 <meta 5 name="viewport" 6 content="height=device-height,width=device-width,initial-scale=1.0" 7 /> 8 <style type="text/css"> 9 body { 10 width: 100%; 11 height: 100%; 12 margin: 0; 13 padding: 0px; 14 /* background contains one extra transparent.gif because we want trick the 15 contentful paint detection; We want to make sure the background is loaded 16 before the test starts so we always wait for the contentful paint timestamp 17 to exist, however, gradient isn't considered as contentful per spec, so Gecko 18 wouldn't generate a timestamp for it. Hence, we added a transparent gif 19 to the image list to trick the detection. */ 20 background: 21 url("/assets/www/transparent.gif"), 22 linear-gradient(135deg, red, white); 23 } 24 25 #one { 26 background-color: red; 27 width: 100%; 28 height: 33%; 29 } 30 31 #two { 32 background-color: green; 33 width: 100%; 34 height: 33%; 35 } 36 37 #three { 38 background-color: blue; 39 width: 100%; 40 height: 33%; 41 } 42 </style> 43 </head> 44 <body> 45 <div id="one"></div> 46 <div id="two"></div> 47 <div id="three"></div> 48 <script> 49 document.getElementById("two").addEventListener("touchstart", e => { 50 console.log("preventing default"); 51 e.preventDefault(); 52 }); 53 54 document.getElementById("three").addEventListener("touchstart", () => { 55 console.log("not preventing default"); 56 }); 57 </script> 58 </body> 59 </html>