Window focus() Method
Assure that the new window GETS focus (send the new window to the front):
myWindow.document.write("<p>A new window!</p>"); // Some text in the new window
myWindow.focus(); // Assures that the new window gets focus
More "Try it Yourself" examples below.
Definition and Usage
The focus() method sets focus to the current window.
Tip: Use the blur() method to remove focus from the current window.
Note: This method makes a request to bring the current window to the foreground. It may not work as you expect in all browsers, due to different user settings.
The numbers in the table specify the first browser version that fully supports the method.
|No return value|
Assure that the new window does NOT get focus (send the new window to the background):
myWindow.document.write("<p>This is 'myWindow'</p>");
myWindow.blur(); // Assures that the new window does NOT get focus);