[Chapter 21] Reference: Element.onfocus()
Author: David Flanagan
Date: Fri Aug 29 11:15:37 1997

#

| Chapter 21 JavaScript Reference |

# Element.onfocus() Handler

## Name

Element.onfocus() Handler---invoked when a form element gains focus

## Availability

Navigator 2.0, Internet Explorer 3.0

## Synopsis

    element.onfocus

## Description

The `onfocus()` event handler of a form element is invoked by the web browser when the user transfers the keyboard focus to that element. Note that it is not invoked when focus is programmatically transfered with the `focus()` method.

The `onfocus()` event handler is a function defined through the `onFocus` attribute of the HTML tag that defined the element. The value of this attribute is a string that may contain any number of JavaScript statements, separated by semicolons. In Navigator 3.0, the `onfocus()` event handler may also be defined by assigning a function directly to the `onfocus` property of the element.

The `onfocus()` event handler is available for all form elements except the Hidden element. For Navigator 2.0 and 3.0 on Unix platforms, however, it is only invoked for the text-entry elements: Text, Textarea, Password and FileUpload. Note that in Navigator 3.0, the Window object also defines an `onfocus()` event handler.

## See Also

"Element", "Element.onblur()", "Element.onchange()", "Element.onclick()"

Element.onclick() |  | Element.options[]