Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Window focus() method

Window focus() method

Window Object Reference Window Object


Definition and Usage

The focus() method sets the focus to the current window, bringing it to the front (near the screen).

Syntax

window.focus()


Browser support

Method
focus() Yes Yes Yes Yes Yes

Example

Example

Ensure the new window gets focus (before sending the new window):

function

openWin

(

)

{

myWindow

=

window

.

open

(

'

'

,

'

'

,

'

width=200,height=100

'

)

;

myWindow

.

document

.

write

(

"

This is 'my window'

"

)

;

myWindow

.

focus

(

)

;

}

Try it »


More examples

Ensure the new window does not get focus


Window Object Reference Window Object