JavaScript: The Definitive Guide

Previous Chapter 21
JavaScript Reference
Next
 

Element.focus() Method

Name

Element.focus() Method---give keyboard focus to a form element

Availability

Navigator 2.0, Internet Explorer 3.0

Synopsis

element.focus()

Arguments

none

Returns

nothing

Description

The focus() method of a form element transfers keyboard focus to that element without calling the onfocus() event handler. That is, it makes the element the active one with respect to keyboard navigation and keyboard input. Thus, if you call focus() for a Text element, then any text the user types will appear in that text element. Or, if you call focus() for Button element, then the user will be able to invoke that button from the keyboard.

All form elements, except the Hidden element support the focus() method. Unfortunately, not all platforms support keyboard navigation equally well. In Navigator 2.0 and 3.0 for Unix platforms, the focus() method is only functional for those form elements that display text: Text, Textarea, Password and FileUpload.

See Also

"Element", "Element.blur()", "Element.onfocus()"


Previous Home Next
Element.defaultValue Book Index Element.form

HTML: The Definitive Guide CGI Programming JavaScript: The Definitive Guide Programming Perl WebMaster in a Nutshell
This HTML Help has been published using the chm2web software.