Tim said:
Hi all,
How can I close a child window from the parent window, even if I don't know
the child's name?
I hope there's something like a window.childs array that I can use..
There isn't, unless you create it yourself. For this you won't need to name
the popup, only to store a reference to the created child:
<script type="text/javascript">
childs = [];
function createWin(url) {
childs[childs.length] = window.open(url, '',
'width=500,height=500');
return childs.length;
}
function removeChilds() {
for (var i = 0; i < childs.length; i++) {
childs
.close();
}
childs = [];
return childs.length;
}
</script>
.....
<form>
Current number of child windows:
<input type="text" name="child_count" value="0" /><br />
<input type="button" value="Create child"
onClick="form.child_count.value = createWin('')" />
<input type="button" value="Remove all children"
onClick="form.child_count.value = removeChilds()" />
</form>
JW