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

L

liu

I have some thumbnails and once clicked it creates a new window. I
don't want extra windows everywhere so I'd like it to auto-close when
it's in the background.

I've found <body onBlur="self.close()" onClick="self.close()"> to do
the trick, but some windows are longer than 1 page that a user need to
scroll the window to see it. With the script above, it closes even
when clicked. I took onClick="self.close()" out but it still does the
same thing.

How do I make it so that it only closes when it's not the top window?

Thanks for the help,

liu
 
E

Evertjan.

liu wrote on 21 jul 2007 in comp.lang.javascript:
I have some thumbnails and once clicked it creates a new window. I
don't want extra windows everywhere so I'd like it to auto-close when
it's in the background.

I've found <body onBlur="self.close()" onClick="self.close()"> to do
the trick, but some windows are longer than 1 page that a user need to
scroll the window to see it. With the script above, it closes even
when clicked. I took onClick="self.close()" out but it still does the
same thing.

How do I make it so that it only closes when it's not the top window?

Thanks for the help,

My idea is NOT to use a "new window", read "pop-up".
It could be changed to a sepreate tab, overhere that is, or be refused by
pop-up blockers.

Use a absolute div that comes in front of your normal layout,
like in "Overlib" [use "sticky" version] and many other applications,

<http://www.bosrup.com/web/overlib/>
or
<http://www.macridesweb.com/oltest/>

or more appropriate in this NG, write one yourself.
 
A

ASM

En réponse à liu qui nous a susurré, en date du : 21/07/07 15:48, le
message sibyllin suivant :
I have some thumbnails and once clicked it creates a new window. I
don't want extra windows everywhere so I'd like it to auto-close when
it's in the background.

in main window's page :

<body onfocus="if(!popup || popup.closed)'';else popup.close();">

aptenting 'popup' is the JS name of your popup
I've found <body onBlur="self.close()" onClick="self.close()"> to do
the trick, but some windows are longer than 1 page

you mean "longer than one screen height" (your screen height !)
How do I make it so that it only closes when it's not the top window?

why do not you leave user to do what he wants with his windows ?
can't he close his windows using their "normal" close button ?

If you really wants to offer window-closer-accessory to user when end of
page is reached, put there your button

<p style="text-align:center">
<a href="javascript:self.close()"
style="border:3px outset #666;padding:2px 10px;
text-decoration:none;">Close this window</a>
</p>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,815
Latest member
treekmostly22

Latest Threads

Top