Element.requestPointerLock()

翻译不完整。 请帮助我们翻译这篇文章!

这是一个实验中的功能
此功能某些浏览器尚在开发中,请参考浏览器兼容性表格以得到在不同浏览器中适合使用的前缀。由于该功能对应的标准文档可能被重新修订,所以在未来版本的浏览器中该功能的语法和行为可能随之改变。

Element.requestPointerLock() 方法允许您异步地请求将鼠标指针锁定在指定元素上。

若想追踪请求成功还是失败,则需要在 Document 级别监听 pointerlockchangepointerlockerror 事件。

语法

instanceOfElement.requestPointerLock();

规范

规范 状态 备注
Pointer Lock
requestPointerLock()
Candidate Recommendation

浏览器兼容性

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
requestPointerLockChrome Full support Yes
Full support Yes
Full support Yes
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Edge Full support 13Firefox Full support 50
Full support 50
Full support Yes
Prefixed
Prefixed Implemented with the vendor prefix: moz
IE No support NoOpera Full support YesSafari Full support 10WebView Android Full support Yes
Full support Yes
Full support Yes
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Chrome Android Full support Yes
Full support Yes
Full support Yes
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Firefox Android Full support YesOpera Android Full support YesSafari iOS ? Samsung Internet Android Full support Yes
Full support Yes
Full support Yes
Prefixed
Prefixed Implemented with the vendor prefix: webkit

Legend

Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown
Requires a vendor prefix or different name for use.
Requires a vendor prefix or different name for use.

相关链接