Document: gotpointercapture event

我们的志愿者还没有将这篇文章翻译为 中文 (简体)加入我们帮助完成翻译
您也可以阅读此文章的English (US)版。

The gotpointercapture event is fired when an element captures a pointer using setPointerCapture().

Bubbles No
Cancelable No
Interface PointerEvent
Event handler property ongotpointercapture

Examples

This example gets a <p> element and listens for the gotpointercapture event. It then calls setPointerCapture() on the element on a pointerdown event, which will trigger gotpointercapture.

const para = document.querySelector('p');

document.addEventListener('gotpointercapture', () => {
  console.log('I\'ve been captured!')
});

para.addEventListener('pointerdown', (event) => {
  para.setPointerCapture(event.pointerId);
});

The same example, using the ongotpointercapture event handler property:

const para = document.querySelector('p');

document.ongotpointercapture = () => {
  console.log('I\'ve been captured!')
};

para.addEventListener('pointerdown', (event) => {
  para.setPointerCapture(event.pointerId);
});

Specifications

Specification Status
Pointer Events Recommendation

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
gotpointercapture eventChrome Full support 57Edge ? Firefox Full support 59IE ? Opera Full support 44Safari ? WebView Android Full support 57Chrome Android Full support 57Firefox Android No support NoOpera Android Full support 43Safari iOS ? Samsung Internet Android ?

Legend

Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown

See also

文档标签和贡献者

此页面的贡献者: Wind1808, mfuji09, mdnwebdocs-bot, wbamberg
最后编辑者: Wind1808,