--- title: GlobalEventHandlers.onpointerdown slug: Web/API/GlobalEventHandlers/onpointerdown translation_of: Web/API/GlobalEventHandlers/onpointerdown ---
{{ApiRef("HTML DOM")}}

 {{event("pointerdown")}} 事件的 {{domxref("GlobalEventHandlers","全局事件处理程序")}} 

语法

var downHandler = targetElement.onpointerdown;

返回值

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

示例

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

<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 Status Comment
{{SpecName('Pointer Events 2','#widl-GlobalEventHandlers-onpointerdown', 'onpointerdown')}} {{Spec2('Pointer Events 2')}} Non-stable version
{{SpecName('Pointer Events', '#widl-GlobalEventHandlers-onpointerdown', 'onpointerdown')}} {{Spec2('Pointer Events')}} Initial definition

浏览器支持

{{CompatibilityTable}}

Feature Chrome Edge Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support {{CompatChrome(55.0)}} {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatIE("10")}} {{CompatOpera(42)}} {{CompatNo}}
Feature Android Android Webview Edge Firefox Mobile (Gecko) Firefox OS IE Mobile Opera Mobile Safari Mobile Chrome for Android
Basic support {{CompatNo}} {{CompatChrome(55.0)}} {{CompatVersionUnknown}} {{CompatNo}} {{CompatNo}} {{CompatIE("10")}} {{CompatOperaMobile(42)}} {{CompatNo}} {{CompatChrome(55.0)}}

 

参阅