onFocus (Event handler)

When the form element is selected for entry.

Availability:

JavaScript - 1.0
JScript - 3.0
Internet Explorer - 3.0
Netscape - 2.0
Opera browser - 3.0
Property/method value type:Boolean primitive
JavaScript syntax:-myObject.onfocus = aHandler
Supported by objects:A, Anchor, APPLET, AREA, BUTTON, CAPTION, Checkbox, DIV, Embed, FIELDSET, FileUpload, IMG, Input, Layer, LEGEND, MARQUEE, OBJECT, Password, RadioButton, ResetButton, SubmitButton, TABLE, TEXTAREA, TextCell, Url
HTML syntax:

<BODY onFocus="aHandler">
<FRAMESET onFocus="aHandler">
<HTMLTag onFocus="aHandler">
<INPUT onFocus="aHandler">
Argument list:aHandlerA reference to a function object to handle the event

When the input focus is directed onto a control, the browser will generally highlight the item to indicate that the cursor is localized there and that any keyboard input will affect that <INPUT> item.

DOM level 2 refers to this as a DOMFocusIn event, which employs event bubbling for its propagation and cannot be canceled.

In MSIE, you can hide the visible effect of an object acquiring focus by means of the hideFocus property on HTML elements.

Warnings:

See also:Element.hideFocus, Event, Event handler, Event model, Event names, Event object, Event.returnValue, Handler, Input.blur(), Input.focus(), onBlur, Password object, Semantic event, UIEvent object, Window.onfocus