By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,478 Members | 1,610 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,478 IT Pros & Developers. It's quick & easy.

List of all Child Windows ?

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


P: n/a
In article <42******@usenet01.boi.hp.com>, me**********@hp.com enlightened us
with...
is it possible to get a list of all child windows (poped from a parent
window) ?
and close all of them ?


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

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

thanks for help


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

This discussion thread is closed

Replies have been disabled for this discussion.