aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/globaleventhandlers/onpointerleave/index.html
blob: 38e47c7b1949cc6a743719840b5f525ba240005d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
---
title: GlobalEventHandlers.onpointerleave
slug: Web/API/GlobalEventHandlers/onpointerleave
translation_of: Web/API/GlobalEventHandlers/onpointerleave
---
<div>{{APIRef("HTML DOM")}}</div>

<p><span class="seoSummary">就像在{{domxref("Element")}}{{domxref("Window")}}中点击类似,在某目标区域内,发生触点(鼠标指针,触摸等)行为时会触发源于{{event("pointerleave")}}事件{{domxref("GlobalEventHandlers","global event handler", "", 1)}}行为。 这个事件本身属于 <a href="/en-US/docs/Web/API/Pointer_events">Pointer Events API</a> 的一部分。</span></p>

<h2 id="语法">语法</h2>

<pre class="syntaxbox">var <var>leaveHandler</var> = <em>EventTarget</em>.onpointerleave;

<em>EventTarget</em>.onpointerleave = <em>leaveHandler</em>;</pre>

<h3 id="返回值">返回值</h3>

<dl>
 <dt><code>leaveHandler</code></dt>
 <dd>{{event("pointerleave")}} 事件会执行{{domxref("EventListener")}} 监听器会委托执行用以发送给目标。</dd>
</dl>

<h2 id="样例">样例</h2>

<p>这个样例展示了两种使用 <code>onpointerleave</code> 来设置元素 <code>pointerleave</code> 事件处理器的方式。</p>

<pre class="brush: js">&lt;html&gt;
&lt;script&gt;
function leaveHandler(ev) {
 // 执行 pointerleave event 事件
}
function init() {
 var el=document.getElementById("target1");
 el.onpointerleave = leaveHandler;
}
&lt;/script&gt;
&lt;body onload="init();"&gt;
&lt;div id="target1"&gt; Touch me ... &lt;/div&gt;
&lt;div id="target2" onpointerleave="leaveHandler(event)"&gt; Touch me ... &lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>

<p>查看 <a href="/en-US/docs/Web/API/Pointer_events/Using_Pointer_Events">Using Pointer Events</a> 以了解更多详情。</p>

<h2 id="规格">规格</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">名称</th>
   <th scope="col">状态</th>
   <th scope="col">备注</th>
  </tr>
  <tr>
   <td>{{SpecName('Pointer Events 2','#widl-GlobalEventHandlers-onpointerleave', 'onpointerleave')}}</td>
   <td>{{Spec2('Pointer Events 2')}}</td>
   <td>Non-stable version</td>
  </tr>
  <tr>
   <td>{{SpecName('Pointer Events', '#widl-GlobalEventHandlers-onpointerleave', 'onpointerleave')}}</td>
   <td>{{Spec2('Pointer Events')}}</td>
   <td>Initial definition</td>
  </tr>
 </tbody>
</table>

<h2 id="浏览器支持情况">浏览器支持情况</h2>



<p>{{Compat("api.GlobalEventHandlers.onpointerleave")}}</p>

<h2 id="参考">参考</h2>

<ul>
 <li><a href="/en-US/docs/Web/API/Pointer_events">Pointer events</a></li>
 <li><a href="/en-US/docs/Web/API/Pointer_events/Using_Pointer_Events">Using pointer events</a></li>
 <li>{{event("pointerleave")}} 以及它实现的 {{domxref("PointerEvent")}} 接口</li>
</ul>