Window focus()
Examples
Open a new window and set focus to it:
const myWindow = window.open("", "", "width=200, height=100");
myWindow.focus();
Try it Yourself »
Open a new window and blur it:
const myWindow = window.open("", "", "width=200, height=100");
myWindow.blur();
Try it Yourself »
Description
The focus()
method sets focus to a window.
The blur()
method removes focus from a window.
Note
The focus()
method makes a request to bring a window to the front.
It may not work as you expect, due to different user settings.
See Also:
Syntax
window.focus()
Parameters
None |
Return Value
NONE |
Browser Support
focus()
is supported in all browsers:
Chrome | Edge | Firefox | Safari | Opera | IE |
Yes | Yes | Yes | Yes | Yes | Yes |
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.