posted 18 years ago
I want my users to be able to click on a link, and if the specified window has already been opened, I want to change focus to that window, rather than re-opening the page.
Here is the code that I have:
function openAppWindow(url, target) {
newwindow = window.open(url, target, 'width=1024,height=768,resizable=no,scrollbars=yes,status=no,toolbars=no');
newwindow.focus();
}
However, I want to get the window reference without having to call window.open. The reason is that this is an application, and user could be three screens in when they go out and do something else in another popup window. Then when they want to come back, I'd like them to be able to click on the link to go back to the popup (instead of requiring them to find the appropriate window in their task bar). If I do window.open, then it will run the first action again, and they'll have to click through a few things again to get back to where they were.
So, I'm wondering, is it possible to get a handle on the window reference without calling the window.open method? If window.open can find the appropriate window using the target, I would think I'd be able to, too, but I haven't been able to find anything that says how to do it. I have seen several places that have you store the reference in a var, but I could have several popup windows open at one time, and I don't think it's very reasonable to require me to have a separate variable and method for each possible popup in my application (i.e. different functions do not share the same popup window; each function has its own window so you can do multiple things at a time).