JavaScript: The Definitive Guide

Previous Chapter 21
JavaScript Reference
Next
 

Element.blur() Method

Name

Element.blur() Method---remove keyboard focus from a form element

Availability

Navigator 2.0, Internet Explorer 3.0

Synopsis

element.blur()

Arguments

none

Returns

nothing

Description

The blur() method of a form element removes keyboard focus from that element without invoking the onblur() event handler; it is essentially the opposite of the focus() method. The blur() method does not transfer keyboard focus anywhere, however, so the only time that it is actually useful to call this method is directly before you plan to transfer keyboard focus elsewhere with the focus() method, when you don't want the onblur() event handler to be triggered. That is, by removing focus explicitly from the element, you won't be notified when it is removed implicitly by a focus() call on another element.

In fact, because it is poor user-interface design to remove keyboard focus without transferring it somewhere else, Internet Explorer 3.0 does not actually remove keyboard focus when you call blur(). Instead, on this platform, calling blur() on a form element simply puts that element in a special state so that it won't trigger its onblur() event handler when focus actually is transferred somewhere else (either by the program or by the user.) Since this is the only reasonable use for blur() anyway, this incompatibility should not be a problem.

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

See Also

"Element", "Element.focus()", "Element.onblur()"


Previous Home Next
Element Book Index Element.checked

HTML: The Definitive Guide CGI Programming JavaScript: The Definitive Guide Programming Perl WebMaster in a Nutshell
Hosted by uCoz