Element.releasePointerCapture()

Releases (stops) pointer capture that was previously set for a specific (PointerEvent) pointer.

See the Element.setPointerCapture() method for a description of pointer capture and how to set it for a particular element.

Syntax

targetElement.releasePointerCapture(pointerId);

Arguments

pointerId
The identifier for a pointer event.

Return value

If pointerId does not match any the active pointers, this method returns void and throws a DOMException with the name InvalidPointerId.

Example

<html>
<script>
function downHandler(ev) {
 var el=document.getElementById("target");
 // Element "target" will receive/capture further events
 el.setPointerCapture(ev.pointerId);
}
function cancelHandler(ev) {
 var el=document.getElementById("target");
 // Release the pointer capture
 el.releasePointerCapture(ev.pointerId);
}
function init() {
 var el=document.getElementById("target");
 // Register pointerdown and pointercancel handlers
 el.onpointerdown = downHandler;
 el.onpointercancel = cancelHandler;
}
</script>
<body onload="init();">
<div id="target"> Touch me ... </div>
</body>
</html>

Specifications

Specification Status Comment
Pointer Events – Level 2
The definition of 'releasePointerCapture' in that specification.
Working Draft Non-stable version.
Pointer Events
The definition of 'releasePointerCapture' in that specification.
Recommendation Initial definition.

Browser compatibility

We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help!

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 35[1] 59 (59) 10 -ms
11
? No support
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support ? 35[1] 29.0 (29)[2] 10 -ms
11
? No support

[1] This was implemented in bug 248918.

[2] Supported behind the preference dom.w3c_pointer_events.enabled, defaulting to false.

 

See also

Document Tags and Contributors

Contributors to this page: chrisdavidmills, erikadoyle, rolfedh, AFBarstow
Last updated by: chrisdavidmills,