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:
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.
Super Moderator
Featured Poster
Reputation Points: 3241
Solved Threads: 719
Failure as a human
Offline 8,873 posts
since Jun 2006