469,364 Members | 2,469 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,364 developers. It's quick & easy.

closing a child window from parent

Tim
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..

Tia, Tim
Jul 20 '05 #1
5 9037

"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,height=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_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

Jul 20 '05 #2
Tim
"Janwillem Borleffs" <jw@jwscripts.com> wrote >
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:


So I can't close any pop-ups that I did not open by my own javascript..?
(I'd like to close the annoying pop-ups from my free webspace account).

Jul 20 '05 #3

"Tim" <no****@nowhere.not> schreef in bericht
news:bn**********@news1.tilbu1.nb.home.nl...

So I can't close any pop-ups that I did not open by my own javascript..?
(I'd like to close the annoying pop-ups from my free webspace account).


Not without a reference. BTW, those popups enable your free account. When
you don't like them why don't you search for a cheap payed service?
JW

Jul 20 '05 #4
Tim wrote:
(I'd like to close the annoying pop-ups from my free webspace account).


You do know that this will most certainly violate your contract
with your service provider which could cost you your account?

You do know that people helping you to do this may become subject
to civil liability if not to criminal prosecution?
PointedEars, IANAL

Jul 20 '05 #5
Thomas 'PointedEars' Lahn <Po*********@web.de> writes:
Tim wrote:
(I'd like to close the annoying pop-ups from my free webspace account).
You do know that this will most certainly violate your contract
with your service provider which could cost you your account?


That is most likely correct.
You do know that people helping you to do this may become subject
to civil liability if not to criminal prosecution?


That is most likely *not* correct.
Definitly not criminal prosecution, unless they can somehow use the DMCA,
and I doubt that is possible.

/L, IANAL either.
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Ron L | last post: by
1 post views Thread by Chris Bruce | last post: by
1 post views Thread by jd | last post: by
19 posts views Thread by zacks | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.