Window focus()Method
Window Object
Definition and Usage
The focus() method sets focus to the current window, that is, brings the window 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("<p>This is 'my window'</p>");
myWindow.focus();
}
Try it yourself »
More Examples
Ensure the new window does not get focus
Window Object Other Extensions