Forum Moderators: open
Say the user clicks on a link, gets that subpage, and then alt-tabs back to the original page, leaving the subpage open and hidden behind the original window.
The user clicks on a second link. The page loads in that already created window, but it doesn't come to the top. So the user thinks nothing happened. This happens to me all the time when surfing.
What onclick JS can I put in the 4 links so that the page named 'subpage' will raise to the top?
Or do I need to do the whole thing with JS, window.open's, and all?
In the head write a small javascript function to close the window, and then in the <body> tag use onBlur="runMyFunction()". This will then close the child window if the focus is removed from it.
I wouldn't really recommend it though. If the user is on the child page, gets a new email, clicks on their mail client (thus removing focus from the child window), the window will close... leading to extreme confusion and annoyance on the users part!
So I guess, what I'm really looking for is the real code that does this pseudocode:
<a href="www.othersite.com/new_window" target=subwindow onclick="if exists(new_window) then focus(new_window)">
G.
Anyways, good luck.
function openWindowNav(url,name) {
popupWin = window.open(url,name, 'menubar=1,scrollbars=1,location=1,
toolbar=1,resizable=1,status=1,
width='+(screen.width * .8)+',height='+(screen.height * .7)+',left=40,top=40')
popupWin.focus()
}
Note that I split the 1st line in the function into 3 for posting. It surely won't run like that!
However, the simplest and most effective solution is to put the following in the code that will be loaded into the new window:
<body onload="self.focus();">
Having pages load into one window instead of a new window every time has many definite advantages for the user.
I have a similiar page that employs about a dozen pop-up (child) windows to present additional info to a resource. I use the same unique target name in the <a> tag for each of these and define their size according to the amount of content they contain.
If, as the poster suggests, I use alt/tab to return to the parent page and then click on another pop-up link, the new window will occupy the same place as the prior pop-up did, and will stay on top. The only possible problem I can see is that the size dimensions of the first pop-up will be inherited to the next pop-up since the first wasn't closed properly (this happens only once) and BTW, just how many users are closing child windows with alt/tab anyway - LOL
I am using IE6 in standards-compliant mode.