364,083 Members | 5825 Browsing Online
Community for Developers & IT Professionals
Bytes IT Community

List of all Child Windows ?

Mel
P: n/a
Mel
is it possible to get a list of all child windows (poped from a parent
window) ?
and close all of them ?

thanks for help


Jul 23 '05 #1
Share this Question
Share on Google+
2 Replies


kaeli
P: n/a
kaeli
In article <4214a701@usenet01.boi.hp.com>, mel.m.heravi@hp.com enlightened us
with...[color=blue]
> is it possible to get a list of all child windows (poped from a parent
> window) ?
> and close all of them ?
>[/color]

I believe this is only possible if you save handles to them as you open them.

--
--
~kaeli~
Contrary to popular opinion, the plural of 'anecdote' is
not 'fact'.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #2

RobB
P: n/a
RobB
Mel wrote:[color=blue]
> is it possible to get a list of all child windows (poped from a[/color]
parent[color=blue]
> window) ?
> and close all of them ?
>
> thanks for help[/color]

Something like this...

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>untitled</title>
<style type="text/css">

input {
width: 80px;
font-size: 75%;
background: beige;
padding: 2px;
margin: 2px;
}

</style>
<script type="text/javascript">

function popit(n)
{
var w, wname = 'pop' + n;
var l = 100 * n + 100;
var t = 100 * n + 100;
w = window.open('javascript:"<h4>'+wname+'</h4>"',
wname,
'width=200,height=200,left='+l+',top='+t+',status= 0');
addName(wname);
return false;
}

function addName(wname)
{
self.name += (wname + '@');
}

function closeByName(wname)
{
window.open('javascript:"<script>window.close()<\/script>"', wname);
}

function closeAll()
{
var wname,
wcoll = self.name.split('@');
self.name = '';
for (var i = 0, l = wcoll.length; i < l; ++i)
if (wname = wcoll[i])
closeByName(wname);
return false;
}

</script>
</head>
<body>
<form>
<input id="w1" type="button"
value="open pop 1"
onclick="popit(1)" />
<br />
<input id="w2" type="button"
value="open pop 2"
onclick="popit(2)" />
<br />
<input id="w3" type="button"
value="open pop 3"
onclick="popit(3)" />
<br /><br />
<input id="ca" type="button"
value="close all"
onclick="closeAll()" />
</form>
</body>
</html>

Saves the popup name in - where else? - the name string of the opener
window. You can then get the (popup window) object back by calling
..open() again & using that name. The browser won't allow two windows
with the same name, so .open() simply loads a closer script in the
original. Storing it in the opener's name guarantees persistence across
pages (yours, anyway). No guarantees with this one...

Jul 23 '05 #3

Post your reply

Help answer this question



Didn't find the answer to your JavaScript / Ajax / DHTML question?

You can also browse similar questions: JavaScript / Ajax / DHTML