--- title: GlobalEventHandlers.onpointermove slug: Web/API/GlobalEventHandlers/onpointermove tags: - API - GlobalEventHandlers - HTML DOM - PointerEvent - Property - Reference translation_of: Web/API/GlobalEventHandlers/onpointermove ---
{{ApiRef("HTML DOM")}}

一个{{domxref("GlobalEventHandlers","global event handler")}}(全局事件) {{event("pointermove")}} 事件.

语法

var moveHandler = targetElement.onpointermove;

返回值

moveHandler
返回 targetElement 元素的pointermove事件处理函数.

示例

下面展示了两种设置元素pointermove事件处理函数的方法.

<html>
<script>
function moveHandler(ev) {
 // 此处添加事件处理语句
}
function init() {
 var el=document.getElementById("target1");
 el.onpointermove = moveHandler;
}
</script>
<body onload="init();">
<div id="target1"> Touch me ... </div>
<div id="target2" onpointermove="moveHandler(event)"> Touch me ... </div>
</body>
</html>

规范

Specification Status Comment
{{SpecName('Pointer Events 2','#widl-GlobalEventHandlers-onpointermove', 'onpointermove')}} {{Spec2('Pointer Events 2')}} Non-stable version
{{SpecName('Pointer Events', '#widl-GlobalEventHandlers-onpointermove', 'onpointermove')}} {{Spec2('Pointer Events')}} Initial definition

浏览器兼容性

{{CompatibilityTable}}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support {{CompatChrome("35")}}[1] {{CompatGeckoDesktop(59)}} 10 {{property_prefix("-ms")}}
11
{{CompatUnknown}} {{CompatNo}}
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support {{CompatUnknown}} {{CompatChrome("35")}}[1] {{CompatGeckoMobile("29")}}[2] 10 {{property_prefix("-ms")}}
11
{{CompatUnknown}} {{CompatNo}}

[1] This was implemented in bug 248918.

[2] Supported behind the preference dom.w3c_pointer_events.enabled, defaulting to false.

相关链接