GlobalEventHandlers.onpointerleave
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2020.
就像在Element
或Window
中点击类似,在某目标区域内,发生触点(鼠标指针,触摸等)行为时会触发源于 pointerleave
事件global event handler行为。这个事件本身属于 Pointer Events API 的一部分。
语法
var leaveHandler = EventTarget.onpointerleave; EventTarget.onpointerleave = leaveHandler;
返回值
leaveHandler
-
pointerleave
事件会执行EventListener
监听器会委托执行用以发送给目标。
样例
这个样例展示了两种使用 onpointerleave
来设置元素 pointerleave
事件处理器的方式。
js
<html>
<script>
function leaveHandler(ev) {
// 执行 pointerleave event 事件
}
function init() {
var el=document.getElementById("target1");
el.onpointerleave = leaveHandler;
}
</script>
<body onload="init();">
<div id="target1"> Touch me ... </div>
<div id="target2" onpointerleave="leaveHandler(event)"> Touch me ... </div>
</body>
</html>
查看 Using Pointer Events 以了解更多详情。
规格
Specification |
---|
Pointer Events # the-pointerleave-event |
Pointer Events # dom-globaleventhandlers-onpointerleave |
浏览器兼容性
BCD tables only load in the browser