Window focus() method
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