closing a child window from parent

Discussion in 'Javascript' started by Tim, Oct 19, 2003.

  1. Tim

    Tim Guest

    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
    Tim, Oct 19, 2003
    #1
    1. Advertising

  2. "Tim" <> schreef in bericht
    news:bmu2d2$pvn$1.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.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
    Janwillem Borleffs, Oct 19, 2003
    #2
    1. Advertising

  3. Tim

    Tim Guest

    "Janwillem Borleffs" <> 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).
    Tim, Oct 20, 2003
    #3
  4. "Tim" <> schreef in bericht
    news:bn0rka$nuu$1.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
    Janwillem Borleffs, Oct 20, 2003
    #4
  5. 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
    Thomas 'PointedEars' Lahn, Oct 21, 2003
    #5
  6. Thomas 'PointedEars' Lahn <> 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 -
    Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
    'Faith without judgement merely degrades the spirit divine.'
    Lasse Reichstein Nielsen, Oct 21, 2003
    #6
    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. =?Utf-8?B?U2lsZWVzaA==?=
    Replies:
    4
    Views:
    33,871
    =?Utf-8?B?U29sZWwgU29mdHdhcmU=?=
    Oct 14, 2004
  2. =?Utf-8?B?Vk1J?=

    Closing popup window when closing parent window?

    =?Utf-8?B?Vk1J?=, Feb 14, 2007, in forum: ASP .Net
    Replies:
    3
    Views:
    643
    Thomas Hansen
    Feb 15, 2007
  3. JohnE
    Replies:
    0
    Views:
    1,151
    JohnE
    Jan 10, 2010
  4. thomas
    Replies:
    0
    Views:
    218
    thomas
    Oct 23, 2003
  5. gokul
    Replies:
    3
    Views:
    694
    Grant Wagner
    Dec 2, 2003
Loading...

Share This Page