GlobalEventHandlers.onpointerdown

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.

pointerdown 事件的 全局事件处理程序

语法

var downHandler = targetElement.onpointerdown;

返回值

downHandler

pointerdown 事件触发对象的事件处理程序。

示例

当前示例展示两种方式使用 onpointerdown 去设置元素的 pointerdown 事件处理程序。

js
<html>
<script>
function downHandler(ev) {
 // Process the pointerdown event
}
function init() {
 var el=document.getElementById("target1");
 el.onpointerdown = downHandler;
}
</script>
<body onload="init();">
<div id="target1"> Touch me ... </div>
<div id="target2" onpointerdown="downHandler(event)"> Touch me ... </div>
</body>
</html>

规范

Specification
Pointer Events
# the-pointerdown-event
Pointer Events
# dom-globaleventhandlers-onpointerdown

浏览器兼容性

BCD tables only load in the browser

参见