Window.focus() (Method)

Send a focus event to the window object.


JavaScript - 1.1
JScript - 3.0
Internet Explorer - 4.0
Netscape - 3.0
Opera - 3.0
Property/method value type:undefined
JavaScript syntax:-focus()

This restores focus to the receiving window or frame that the method is executed on. If the focus goes to a frame, then by implication, the window it belongs to becomes active too.

On some platforms this will bring the receiving window to the foreground if it is not already the active window. It is generally better technique to use the focus() method on another window rather than call the blur() method if you want to remove focus from a window. However, that may not always be possible if you want to completely remove focus from all windows. The consequence may be that the window becomes inactive and on some platforms it means the window will be placed at the rear of any other windows on the screen.


See also:Frame object, Input.blur(), Input.focus(), Window object, Window.blur(), Window.onblur, Window.onfocus