Element.requestPointerLock()
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Element.requestPointerLock()
方法允许你异步地请求将鼠标指针锁定在指定元素上。
若想追踪请求成功还是失败,则需要在 Document
级别监听 pointerlockchange
和 pointerlockerror
事件。
语法
instanceOfElement.requestPointerLock();
规范
Specification |
---|
Pointer Lock 2.0 # dom-element-requestpointerlock |
浏览器兼容性
BCD tables only load in the browser