How Do I Bring An Already Existing Open Window To The Front On Top Of Other Windows From Another Windows Code?
Solution 1:
Update: This hasn't worked since Chrome (21+). The workaround is to close/reopen.
The following code works for me on Firefox (Mac & Windows), Safari (Mac & Windows), and IE8 (Windows, of course). I haven't tested IE6 or IE7.
However, it does not work on Chrome for either Mac or Windows. Specifically, clicking the button once creates the pop-up and brings it to the front. However, returning to the original window and clicking the button again does not refocus the popup.
<head><scripttype="text/javascript">var popupWindow = null;
var doPopup = function () {
if (popupWindow && !popupWindow.closed) {
popupWindow.focus();
} else {
popupWindow = window.open("http://google.com", "_blank",
"width=200,height=200");
}
};
</script></head><body><buttononclick="doPopup(); return false">
create a pop-up
</button></body>
Solution 2:
Update: This hasn't worked since Chrome (21+). The workaround is to close/reopen.
opener.focus()
does work. If it doesn't for you, we'll need a test case.
Some things that might cause problems: calling it in an event handler that fires before the button's window gets focus due to the click (but I don't think that'd usually be the case); running it on a browser that stuffs pop-ups into browser tabs instead.
(I agree with Max's comment. Pop-ups with cross-window scripting are generally best avoided.)
Post a Comment for "How Do I Bring An Already Existing Open Window To The Front On Top Of Other Windows From Another Windows Code?"