>> I want it to remain visible or to close automatically when the main window is selected again. <<
smgagaz, thanks for the idea that the new window could close automatically. It's such a direct solution that I smack myself in the head for not coming up with it. The code for automatically closing the new window could go in the BODY tag for the top window's document, like this:
I've been using
That gets tricky on some browsers (like Netscape) which still allow temporary focus for another page. There's also the chance of an infinite loop, if the code ends up on a machine where another open window also has similar code. This is a much more graceful solution.
I just implemented the onBlur=self.close() in a few places and discovered one glitch to watch out for. The moment someone clicks anywhere in the pop-up window, registering that click requires a Blur event (in both IE and NN) and the pop-up window closes -- the link isn't followed, even if it was supposed to open a new window!
This means that any links on the pop-up page are essentially non-functional. With onBlur=self.focus(), the links will load, but stay behind the open pop-up to be viewed when that pop-up is closed by hand.
> the element (whether it be a form or an anchor) gets the focus when you click it.
IT seems that the click can be anywhere on the page, even on the background, and the focus leaves the window -- which closes it. Interesting situation. Even a right click has the effect of closing the window, but only after the menu choice you make is executed (i.e. view source).