Welcome to WebmasterWorld Guest from 54.160.221.82

Forum Moderators: incrediBILL

Message Too Old, No Replies

window on top

     

smagaz

5:42 pm on Jul 28, 2001 (gmt 0)

Inactive Member
Account Expired

 
 


Is it possible , in javascript, to keep a window always on top ?
I open a new small window in a target called "details" and I want it to remain visible or to close automatically when the main window is selected again. Otherwise the small window disappear behind the main one and whenever a new information is asked the small window remains behind and does not appears on top !
Am I clear !?!

thanks
Salva

6:00 pm on July 28, 2001 (gmt 0)

Senior Member

WebmasterWorld Senior Member rcjordan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Apr 22, 2000
posts:9138
votes: 0


Welcome to WebmasterWorld, smagaz.

Yes, it can be done with javascript. Here are a couple of resources:
[developer.irt.org...]
[webreference.com...]

10:45 pm on July 28, 2001 (gmt 0)

Senior Member

WebmasterWorld Senior Member tedster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:May 26, 2000
posts:37301
votes: 0


>> 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:

<body onBlur="self.close()">

I've been using

<body onBlur="self.focus()">

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.

7:37 pm on July 31, 2001 (gmt 0)

Senior Member

WebmasterWorld Senior Member tedster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:May 26, 2000
posts:37301
votes: 0


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.

7:56 pm on July 31, 2001 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:July 4, 2001
posts:997
votes: 0


The same is probably true with form elements. This is because the element(whether it be a form or an anchor) gets the focus when you click it.
8:21 pm on Aug 4, 2001 (gmt 0)

Senior Member

WebmasterWorld Senior Member tedster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:May 26, 2000
posts:37301
votes: 0


> 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).