Window.onfocus (Property)

This event handler is called when a window gains the input focus.

Availability:

JavaScript - 1.1
JScript - 3.0
Internet Explorer - 4.0
Netscape - 3.0
Opera - 3.0
Property/method value type:Function object
JavaScript syntax:-myWindow.onfocus
-myWindow.onfocus = aHandler
-onfocus
-onfocus = aHandler
HTML syntax:<BODY onFocus="aHandler"> <FRAMESET onFocus="aHandler">
Argument list:aHandlerAn event handler function object

A focus event is caused by the user clicking on the receiving window or frame or the window.focus() method being called. When this event is triggered, an onfocus event handler will be invoked.

The onfocus event handler is a function which is represented by an object that is referred to by this property. Because it is stored in a property, you can change the handler by storing a reference to a different function object in this property. At least, you can on MSIE.

You cannot redefine the value of the window.onfocus property from inside the onfocus function handler. This means you can't modify the onfocus behavior while a focus event is in progress.

The handler is registered either by assigning a function to the onfocus property or by defining it with an HTML tag attribute.

Warnings:

See also:onFocus, Window.blur(), Window.focus(), Window.onblur

Property attributes:

DontEnum.