diff options
author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
---|---|---|
committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
commit | 33058f2b292b3a581333bdfb21b8f671898c5060 (patch) | |
tree | 51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/api/element/activate_event/index.html | |
parent | 8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff) | |
download | translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2 translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip |
initial commit
Diffstat (limited to 'files/zh-cn/web/api/element/activate_event/index.html')
-rw-r--r-- | files/zh-cn/web/api/element/activate_event/index.html | 108 |
1 files changed, 108 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/element/activate_event/index.html b/files/zh-cn/web/api/element/activate_event/index.html new file mode 100644 index 0000000000..3185540e78 --- /dev/null +++ b/files/zh-cn/web/api/element/activate_event/index.html @@ -0,0 +1,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><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"> + + <desc>Example: invoke an ECMAScript function from a DOMActivate event</desc> + + <!-- ECMAScript to change the radius --> + <script type="application/ecmascript"><![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); + } + ]]></script> + + <!-- Act on each DOMActivate event --> + <circle cx="300" cy="225" r="100" fill="red"> + <handler type="application/ecmascript" ev:event="DOMActivate"> change(evt); </handler> + </circle> + + <text x="300" y="480" font-family="Verdana" font-size="35" text-anchor="middle"> + Activate the circle to change its size + </text> +</svg> +</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> |