| | |
Javascript: Child windows talking to each other???
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Aug 2007
Posts: 7
Reputation:
Solved Threads: 0
Hi there,
Im trying to design a fun page where a after an onclick on the parent page, several small child windows are opened. Upon clicking the content of any of those windows, I want all of the child windows to close. I can get self.close() to close the clicked window, but I cannot communicate with the other child windows, even if I reference them by their name, ie winName.close()... are there special rules for doing this?
Essentially, Im wondering if child windows can talk to each other, there must be a way for that to happen...?
A miniaturized version of what I am trying to do can be seen here:
http://stevenewberry.com/experimental/randombirds1.html
(click the red square!)
Thanks for any insight you may have...
Im trying to design a fun page where a after an onclick on the parent page, several small child windows are opened. Upon clicking the content of any of those windows, I want all of the child windows to close. I can get self.close() to close the clicked window, but I cannot communicate with the other child windows, even if I reference them by their name, ie winName.close()... are there special rules for doing this?
Essentially, Im wondering if child windows can talk to each other, there must be a way for that to happen...?
A miniaturized version of what I am trying to do can be seen here:
http://stevenewberry.com/experimental/randombirds1.html
(click the red square!)
Thanks for any insight you may have...
You need to enter the reference to the newly created pages in an array which is kept in the main page and use that array to loop through the window references and close them.
Something like this:
Something like this:
Main.html <html> <head> <script> var wnd = new Array(); function openit(id) { if(!wnd[id] || wnd[id].closed) wnd[id] = window.open("Child.html"); else wnd[id].focus(); } function closeEverything() { for(var i = 0; i < wnd.length; ++i) wnd[i].close(); } </script> </head> <body> <form> <input type="button" value="Open1" onclick="openit(0);" /><br/> <input type="button" value="Open2" onclick="openit(1);" /><br/> <input type="button" value="Open3" onclick="openit(2);" /><br/> </form> </body> </html> Child.html <html> <head> <script> function closeAll() { window.opener.closeEverything(); } </script> </head> <body> <form> <input type="button" value="Close Me" onclick="window.close();" /><br/><br /><br /> <input type="button" value="Close all children" onclick="closeAll();" /><br/> </form> </body> </html>
Last edited by ~s.o.s~; Aug 9th, 2007 at 1:38 pm.
I don't accept change; I don't deserve to live.
![]() |
Similar Threads
- Parent/Child Windows References (JavaScript / DHTML / AJAX)
- how can I fix two child windows in a mdi form in vb 4 (Visual Basic 4 / 5 / 6)
- Datagrid to draw a table (C#)
- Help with javascript error with windows xp (Windows NT / 2000 / XP)
- C# : Client windows in client windows (C#)
- Displaying a different bitmap in different child windows? - win32 in C (C)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Frameset and setTimeout
- Next Thread: starrating
| Thread Tools | Search this Thread |
acid2 ajax ajaxcode ajaxexample ajaxhelp ajaxjspservlets animate automatically beta box browser bug calendar captchaformproblem checkbox child class close column createrange() css cursor decimal dependent design disablefirebug dom download dropdown editor element embed engine error events explorer ext file form forms google gwt gxt hiddenvalue highlightedword html htmlform ie8 iframe images index internet java javascript javascripthelp2020 jawascriptruntimeerror jquery jsf jsfile jump libcurl listbox math media microsoft mimic mp4 object onmouseoutdivproblem onmouseover onreadystatechange parent paypal pdf php player post problem progressbar regex runtime scroll search security select shopping size software sql text textarea unicode w3c web website window windowofwords windowsxp wysiwyg \n






