469,337 Members | 5,924 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,337 developers. It's quick & easy.

search for and close all child windows thru parent window

zybernau
hi, all

in javascript
i need to close all the child windows[popup windows] that i have opened through a parent window

scenario:

* here i will be having as many as child window opened and name given to the child window can not be tracked because each will be having a different name, and
* i am using 70 to 80 popup windows [doing seperate operations] through out my page [parent window]
* there can be any number of child windows opened , at the time of user triGgers the event from the parent window to close all the child window that i have opened so far [currently opened child windows]

Thanks in advance

- rajamohan
Mar 22 '07 #1
6 9602
iam_clint
1,208 Expert 1GB
you need to open the windows in an array or something



popup[0] = window.open(yadda);
popup[1] = window.open(yadda);
popup[2] = window.open(yadda);
popup[3] = window.open(yadda);

then you can do something like

for (i=0; i<=popup.length; i++) {
popup[i].close();
}
Mar 22 '07 #2
iam_clint
1,208 Expert 1GB
Expand|Select|Wrap|Line Numbers
  1.  
  2. <script>
  3. var pop = new Array();
  4. function openwins() {
  5. pop[0] = window.open('http://www.google.com', 'test');
  6. pop[1] = window.open('http://www.google.com', 'test1');
  7. pop[2] = window.open('http://www.google.com', 'test2');
  8. pop[3] = window.open('http://www.google.com', 'test3');
  9. pop[4] = window.open('http://www.google.com', 'test4');
  10. }
  11. function closewins() {
  12. for (i=0; i<pop.length; i++) {
  13. pop[i].close();
  14. }
  15. }
  16. </script>
  17. <input type="button" onclick="openwins();" value="Open PopUps">
  18. <input type="button" onclick="closewins();" value="Close PopUps">
  19.  
example.
Mar 22 '07 #3
hi all,

i am having a parent window,
for that many child windows are being opened.
i am having a reference for all the windows which are being opened in javascript as a array variable
[so i am free to close all the windows that are refrenced when needed]

, here for a functionality in my application , i am refershing the page for every 500 secs.

so here the windows opened before 500 secs losts there references in the javascript, so i have no handle to close those windows.
question no 1: is there any way close those orphan windows?

question no 2: is there any way to search for the internet explorer windows which are open and look for the specific parameter in that window and then closing the window[which are orphan]?

please help!!!

Thanks,
Raj.
Nov 16 '07 #4
acoder
16,027 Expert Mod 8TB
I've merged this with an older thread.

Are you sure you need to refresh the whole page? Can you not refresh a part of the page instead to avoid losing references to the child windows?
Nov 17 '07 #5
I've merged this with an older thread.

Are you sure you need to refresh the whole page? Can you not refresh a part of the page instead to avoid losing references to the child windows?
Thanks acoder for merging, and Yes i need to refresh the whole page, because i am extending the application and not creating a new, my change should not affect others flow

is there any other way of doing this[with out having a seperate frame/iframe]

Thanks once again,
Raj
Nov 19 '07 #6
acoder
16,027 Expert Mod 8TB
Once you refresh the window, I think the references to the child windows will be lost. What exactly requires the page to refreshed every half second? Perhaps there is an alternative you haven't thought of.
Nov 19 '07 #7

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by jrefactors | last post: by
10 posts views Thread by olga p. | last post: by
1 post views Thread by mike | 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 zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.