Javascript DOM touchcancel Event via addEventListener() method

Introduction

In JavaScript, using the addEventListener() method:

object.addEventListener("touchcancel",
       myScript);

This example is for touch devices only.

View in separate window

<!DOCTYPE html>
<html>
<body>
<p id="myP">Touch this paragraph while you do something that will interrupt the event. </p>
<p id="demo"></p>

<script>
document.getElementById("myP").addEventListener("touchcancelled", myFunction);
function myFunction() {/*from w w  w  .  j  av  a 2 s .  c o m*/
  document.getElementById("demo").innerHTML = "Touch Cancelled";
}
</script>

</body>
</html>
Bubbles: Yes
Cancelable: Yes
Event type: TouchEvent
Supported HTML tags: All HTML elements



PreviousNext

Related