Javascript examples for Browser Object Model:Window focus
The focus() method sets focus to the current window.
None
No return value
The following code shows how to Assure that the new window GETS focus (send the new window to the front):
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <script> function myFunction() {//from w ww . ja v a 2 s . co m var myWindow = window.open("", "", "width=200,height=100"); myWindow.document.write("<p>A new window!</p>"); myWindow.focus(); } </script> </body> </html>