aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/element/domactivate_event/index.html
blob: 3185540e787dc0b33bd11b33917b229e9769d752 (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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
---
title: 'Element: DOMActivate event'
slug: Web/API/Element/Activate_event
tags:
  - API
  - 事件
  - 参考
translation_of: Web/API/Element/DOMActivate_event
---
<p>{{APIRef}}</p>

<p>{{Deprecated_Header}}</p>

<p>当元素被激活时发生,例如点击鼠标或键盘按键。</p>

<p>当元素被激活,如使用鼠标点击或使用键盘导航并激活至这个元素时, <code><strong>DOMActivate</strong></code> 事件被触发。</p>

<table class="properties">
 <tbody>
  <tr>
   <th scope="row">
    <p class="syntaxbox">Bubbles</p>
   </th>
   <td>
    <p class="syntaxbox">Yes</p>
   </td>
  </tr>
  <tr>
   <th scope="row">
    <p class="syntaxbox">Cancelable</p>
   </th>
   <td>
    <p class="syntaxbox">Yes</p>
   </td>
  </tr>
  <tr>
   <th scope="row">
    <p class="syntaxbox">Interface</p>
   </th>
   <td>
    <p>{{domxref("MouseEvent")}}</p>
   </td>
  </tr>
 </tbody>
</table>

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

<pre>&lt;svg xmlns="http://www.w3.org/2000/svg" version="1.2" baseProfile="tiny"
     xmlns:ev="http://www.w3.org/2001/xml-events"
     width="6cm" height="5cm" viewBox="0 0 600 500"&gt;

  &lt;desc&gt;Example: invoke an ECMAScript function from a DOMActivate event&lt;/desc&gt;

  &lt;!-- ECMAScript to change the radius --&gt;
  &lt;script type="application/ecmascript"&gt;&lt;![CDATA[
    function change(evt) {
      var circle = evt.target;
      var currentRadius = circle.getFloatTrait("r");
      if (currentRadius == 100)
        circle.setFloatTrait("r", currentRadius * 2);
      else
        circle.setFloatTrait("r", currentRadius * 0.5);
    }
  ]]&gt;&lt;/script&gt;

  &lt;!-- Act on each DOMActivate event --&gt;
  &lt;circle cx="300" cy="225" r="100" fill="red"&gt;
    &lt;handler type="application/ecmascript" ev:event="DOMActivate"&gt; change(evt); &lt;/handler&gt;
  &lt;/circle&gt;

  &lt;text x="300" y="480" font-family="Verdana" font-size="35" text-anchor="middle"&gt;
    Activate the circle to change its size
  &lt;/text&gt;
&lt;/svg&gt;
</pre>



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

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>{{SpecName('UI Events', '#event-type-DOMActivate', 'DOMActivate')}}</td>
   <td>{{Spec2('UI Events')}}</td>
  </tr>
 </tbody>
</table>

<h2 id="浏览器兼容性">浏览器兼容性</h2>

<p>{{Compat("api.Element.DOMActivate_event")}}</p>

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

<ul>
 <li>{{domxref("MouseEvent")}}</li>
 <li>{{domxref("Element/mousedown_event", "mousedown")}}</li>
 <li>{{domxref("Element/mouseup_event", "mouseup")}}</li>
 <li>{{domxref("Element/mousemove_event", "mousemove")}}</li>
</ul>