Window focus()Method

Window 对象参考手册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 对象参考手册Window Object Other Extensions