•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 397,851 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,332 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 1584 | Replies: 1
![]() |
•
•
Join Date: Aug 2007
Posts: 4
Reputation:
Rep Power: 0
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 12:38 pm.
"I don't accept change. I don't deserve to live."
"Working a real job is a win if you're lazy, greedy, or unmotivated. If you're average, you fit right in. And if you're above average, the basic terms of employment and premise of the arrangement is against your interests."
"Working a real job is a win if you're lazy, greedy, or unmotivated. If you're average, you fit right in. And if you're above average, the basic terms of employment and premise of the arrangement is against your interests."
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb JavaScript / DHTML / AJAX Marketplace
•
•
•
•
ajax apple asp browser choose computer crack dell development download drm fiji france home ie 7 install internet leopard license linux microsoft microsoft windows mobile newbie news office open operating operating system os parliament phishing photo security server site software source system ubuntu unix upgrade vista vista updates volume web windows windows update windows vista xp
- 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 / 2003)
- 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



Linear Mode