List of all Child Windows ?

Discussion in 'Javascript' started by Mel, Feb 17, 2005.

  1. Mel

    Mel Guest

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

    thanks for help
    Mel, Feb 17, 2005
    #1
    1. Advertising

  2. Mel

    kaeli Guest

    In article <>, 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
    kaeli, Feb 17, 2005
    #2
    1. Advertising

  3. Mel

    RobB Guest

    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)
    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...
    RobB, Feb 17, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jeff Rodriguez
    Replies:
    23
    Views:
    1,116
    David Schwartz
    Dec 9, 2003
  2. bvidinli
    Replies:
    0
    Views:
    284
    bvidinli
    Apr 15, 2008
  3. Jan Christoph
    Replies:
    1
    Views:
    161
    Jan Christoph
    Oct 4, 2007
  4. Replies:
    1
    Views:
    248
  5. Z W
    Replies:
    0
    Views:
    171
Loading...

Share This Page