Javascript DOM touchcancel Event

Introduction

Execute a JavaScript when a touch is interrupted.

Touch events works for touch devices only.

View in separate window

<!DOCTYPE html>
<html>
<body>
<p ontouchcancel="myFunction()">
Touch this paragraph while you do something that will interrupt the event. 
</p>//from  w  ww  .ja v a2s  .c o m
<p id="demo"></p>
<script>
function myFunction() {
  document.getElementById("demo").innerHTML = "Touch Cancelled";
}
</script>

</body>
</html>

The touchcancel event occurs when the touch event gets interrupted.

The touchstart event will only work on devices with a touch screen.

Bubbles: Yes
Cancelable: Yes
Event type: TouchEvent
Supported HTML tags: All HTML elements



PreviousNext

Related