closing a child window from parent

T

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
 
J

Janwillem Borleffs

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
 
T

Tim

Janwillem Borleffs said:
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).
 
J

Janwillem Borleffs

Tim said:
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
 
T

Thomas 'PointedEars' Lahn

Tim said:
(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
 
L

Lasse Reichstein Nielsen

Thomas 'PointedEars' Lahn said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top