Text.onFocus

JavaScript1.0+, JScript1.0+ Nav2+, IE3+, Opera3+ Syntax

onFocus="command"

Description

The onFocus event handler of an instance of a Text object is fired when focus is made on that particular text box. Care should be taken when using this event handler, because it is possible to get into an infinite loop when using onBlur event handler or blur() method.

Example

Listing 7.501 contains three text boxes, one of which has the onFocus event handler intercepted within its tag. The third text box is used for a counter for the number of times the Focus event is fired.

In the script, the event handler calls a function that assigns the second text box focus. The result of this is that when a user tries to click or tab to the first text ...

Get Pure JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.