Easy Tutorial
❮ Met Doc Write Prop Style Borderbottomcolor ❯

Window focus() Method


Definition and Usage

The focus() method sets the focus to the current window, which means bringing the window to the front (closer to the screen).

Syntax

window.focus()

Browser Support

Method
focus() Yes Yes Yes Yes Yes

Example

Ensure the new window gets focus (bring it to the front):

function openWin(){
    myWindow=window.open('','','width=200,height=100');
    myWindow.document.write("<p>This is 'my window'</p>");
    myWindow.focus();
}

More Examples

Ensure the new window does not get focus


❮ Met Doc Write Prop Style Borderbottomcolor ❯