JavaScript手册 
目录
此参考中包含
的内容
轻松上手
简介
操作符
语句
核心
文档
窗口
表单
浏览器
事件和
事件句柄
LiveWire
数据库服务
进程管理服务
实用工具
全局函数
LiveConnect
的Java包
索引
版权
 
【目录】 【上一页】 【下一页】 【索引】

onFocus

Executes JavaScript code when a focus event occurs; that is, when a window, frame, or frameset receives focus or when a form element receives input focus.

事件适用对象Button, Checkbox, FileUpload, Layer, Password, Radio, Reset, Select, Submit, Text, Textarea, Window
实现版本Navigator 2.0
Navigator 3.0: event handler of
Button, Checkbox, FileUpload, Frame, Password, Radio, Reset, Submit, and Window
Navigator 4.0: event handler of Layer

语法

onFocus="handlerText"

参数

handlerTextJavaScript 代码或对一个 JavaScript 函数的调用。

描述

The focus event can result from a focus method or from the user clicking the mouse on an object or window or tabbing with the keyboard. Selecting within a field results in a select event, not a focus event. onFocus executes JavaScript code when a focus event occurs.

A frame's onFocus event handler overrides an onFocus event handler in the BODY tag of the document loaded into frame.

Note that placing an alert in an onFocus event handler results in recurrent alerts: when you press OK to dismiss the alert, the underlying window gains focus again and produces another focus event.

Note

In Navigator 3.0, on some platforms, placing an onFocus event handler in a FRAMESET tag has no effect.

使用的事件属性

type标明了事件的类型。
target标明了事件原来发送的对象。

示例

The following example uses an onFocus handler in the valueField Textarea object to call the valueCheck function.

<INPUT TYPE="textarea" VALUE="" NAME="valueField"
   onFocus="valueCheck()">
See also示例 for onBlur.

参看

onBlur, onChange

要获得关于事件句柄的常规信息,请看“事件的常规信息”

要获得关于事件对象的信息,请看事件


【目录】 【上一页】 【下一页】 【索引】

回页面顶部