471,350 Members | 1,539 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,350 software developers and data experts.

close all child windows when close the main window

>From the main page, there are lots of links to open new window.
i.e. <a href="#" onClick="window.open('child1.html')">Open Child
Window</a>

If I close the main page, I want to close all child windows also. That
means I
need to keep track all handles of the child windows whenever I open a
new
window. Correct? any suggestions on the approach?
Please advise. thanks!!

Jul 23 '05 #1
4 3538
If I close the main page, I want to close all child windows also. That
means I need to keep track all handles of the child windows whenever I
open a
new window.


That won't work if user browses in main window.

IMO the best way is to simply add 'dependent=yes' to popup window
attributes.
Doesn't work everywhere, but when works - it works :)

BTW: never use href="#", put real address there and use return false in
onclick.
This will improve search engine visibility, ensure that windows open in new
window, links can be copied/bookmarked, etc.

--
* html {redirect-to: url(http://browsehappy.pl);}
Jul 23 '05 #2
<jr********@hotmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
From the main page, there are lots of links to open new window.

i.e. <a href="#" onClick="window.open('child1.html')">Open Child
Window</a>

If I close the main page, I want to close all child windows also. That
means I
need to keep track all handles of the child windows whenever I open a
new
window. Correct? any suggestions on the approach?
Please advise. thanks!!


Yes. Wouldn't be hard if you define a Javascript function for opening
windows and save the handles into an array.

Or you could use the ShowModelessDialog() function. Modless dialog boxes
stay in front of their parent window and automatically would close when the
parent closes.
Jul 23 '05 #3
Chung Leong wrote:
<jr********@hotmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
From the main page, there are lots of links to open new window.

i.e. <a href="#" onClick="window.open('child1.html')">Open Child
Window</a>

If I close the main page, I want to close all child windows also. That
means I
need to keep track all handles of the child windows whenever I open a
new
window. Correct? any suggestions on the approach?
Please advise. thanks!!

Yes. Wouldn't be hard if you define a Javascript function for opening
windows and save the handles into an array.

Or you could use the ShowModelessDialog() function. Modless dialog boxes
stay in front of their parent window and automatically would close when the
parent closes.


Modeless Dialogs are also IE-only.

I might be able to understand the OT if this were not posted to
comp.lang.javascript
--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq
Jul 23 '05 #4
"Randy Webb" <Hi************@aol.com> wrote in message
news:io********************@comcast.com...
Chung Leong wrote:
<jr********@hotmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
From the main page, there are lots of links to open new window.
i.e. <a href="#" onClick="window.open('child1.html')">Open Child
Window</a>

If I close the main page, I want to close all child windows also. That
means I
need to keep track all handles of the child windows whenever I open a
new
window. Correct? any suggestions on the approach?
Please advise. thanks!!

Yes. Wouldn't be hard if you define a Javascript function for opening
windows and save the handles into an array.

Or you could use the ShowModelessDialog() function. Modless dialog boxes
stay in front of their parent window and automatically would close when the parent closes.


Modeless Dialogs are also IE-only.

I might be able to understand the OT if this were not posted to
comp.lang.javascript


Oops. Why did the OP cross post into comp.lang.php?
Jul 23 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by jrefactors | last post: by
2 posts views Thread by Guy Babbitt | last post: by
3 posts views Thread by Isabel | last post: by
1 post views Thread by michal.podlewski | last post: by
reply views Thread by XIAOLAOHU | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.