"Tim" <no****@nowhere .not> schreef in bericht
news:bm******** **@news4.tilbu1 .nb.home.nl...
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,heig ht=500');
return childs.length;
}
function removeChilds() {
for (var i = 0; i < childs.length; i++) {
childs[i].close();
}
childs = [];
return childs.length;
}
</script>
.....
<form>
Current number of child windows:
<input type="text" name="child_cou nt" value="0" /><br />
<input type="button" value="Create child"
onClick="form.c hild_count.valu e = createWin('')" />
<input type="button" value="Remove all children"
onClick="form.c hild_count.valu e = removeChilds()" />
</form>
JW