Javascript Bring window to front if already open in window.open?

Update: This hasn’t worked since Chrome (21+). The workaround is to close/reopen.

The window.open() method returns an object that represents the new window. You just need to window.focus() it:

var w = window.open ("url","winName","location=0,width=300,height=214");
w.focus();

Or simply:

window.open("url","winName","location=0,width=300,height=214").focus();

Leave a Comment