blob: 4c204055afde6d3e36ee0d696ab27cbdb6ab265d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
<!DOCTYPE html>
<style>
body, div, html {
height: 100%;
width: 100%;
overflow: hidden;
}
p {
margin-bottom: 1000px;
margin-right: 1000px;
}
</style>
<body>
<div id="blocker">
<p>This page blocks 'touchstart' and 'touchmove'.</p>
</div>
<script>
function doSomethingUnimportant(e) {
return false !== e;
}
function preventDefault(e) {
e.preventDefault();
}
document.addEventListener("touchstart", doSomethingUnimportant, {passive: false});
document.addEventListener("touchmove", doSomethingUnimportant, {passive: false});
function messageHandler(e) {
let msg = e.data;
let element = document.querySelector(msg.query);
if (msg.prevent) {
element.addEventListener(msg.event_type, preventDefault, {passive: false});
} else {
element.addEventListener(msg.event_type, doSomethingUnimportant);
}
e.source.postMessage(msg, "*");
}
window.addEventListener("message", messageHandler);
</script>
</body>
|