Forum Moderators: open
But on a lot of systems, as soon as the main window goes back to the main view, it covers up the window I just opened.
Is there any way to keep the new window on top? I've tried several things, like recapturing focus any time it's lost (problem-it becomes a modal window), capturing focus after a short period of time, like 1 second (problem-I still want to be able to allow the user to click on the main window and view it without the second window covering it up later). And I've even tried to put something in the main page the opens the window from the main page if a certain url parameter is passed in. But that causes the window to be opened every time you refresh or go to a different page and then back again.
Help!
having my main window call:
window.open(...)
And then my new window:
<body onload="parent.history.back();">
?
No, I never thought of that. I'll give it a shot. But from past experience, I think if I reload the second window (i.e. hit F5), it will also take the main window back yet again, and I don't want that.
Is there a way I could set a status variable that doesn't get reset when the page gets reloaded?
I'm trying to handle making the top window go back a page when my second window opens. Something like this:
<body onload="parent.history.back();">
But nothing happens. It looks like "parent" and "this" are the same thing here. What's going on? How do I alter the main window? Does it have to have a name?
And then in the subwindow I can set history back like this:
mainWindow.history.back();
However, if I reload, the mainWindow object no longer exists in my subwindow. Is there a javascript function to check whether a variable exists so that I don't pop up any error boxes?
I would just do opener.history.back() or whatever is right, but then if the subwindow got refreshed, it would send the main window backward yet again, and I don't want that.
Now, I suppose I could pop up two windows, one of which would just call history.back() on the first window, pop open a third window, and then close itself, which would probably work. But I'm a big fan of simple solutions, so 3 html pages to pop up one window seems like overkill.
So unless someone knows how to check for the existence of a variable without causing a runtime error, I'm going to just leave it the last way I did it: The main window will send a reference to itself to the second window after popping it up. The second window will call history.back() on the caller window, and then request focus. That will work most of the time, since I'm eliminating all the buttons and other functionality of the second window, so the only way they'll have to refresh is if some server error occurs and the ActiveX object that appears in the window (the only thing the window is for) doesn't show up. And if that happens, I expect most typical users would just close the window and try the original link again anyway. Besides, a normal person might not think it's so strange to get a runtime error right after a server error.
Thanks.