aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/globaleventhandlers/onfocus/index.html
blob: 8e9b37c28e94bc6bee70b854596a5cf22a4ea46b (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
---
title: GlobalEventHandlers.onfocus
slug: Web/API/GlobalEventHandlers/onfocus
translation_of: Web/API/GlobalEventHandlers/onfocus
---
<div>{{ ApiRef("HTML DOM") }}</div>

<h3 id="概述">概述</h3>

<p><strong>onfocus</strong> 属性用来获取或设置当前元素的<code>focus</code>事件的事件处理函数.</p>

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

<pre class="eval">element.onfocus = <em>event handling code</em>
</pre>

<h3 id="备注">备注</h3>

<p>当前元素获得键盘焦点时会触发<code>focus</code>事件.</p>

<p>在IE中,几乎所有类型的元素都会触发<code>focus</code>事件, 但在Gecko中,只有少数几种类型的元素会触发<code>focus</code>事件.</p>

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

<p>不属于任何公开的规范.</p>

<p>{{ languages( { "fr": "fr/DOM/element.onfocus","en": "en/DOM/element.onfocus" } ) }}</p>