popup that closes itself and other popups

Ask a Question related to Macromedia Dynamic HTML, Design and Development.

  1. #1

    Default popup that closes itself and other popups

    Hi.

    I'm now working on a website with several links that open multiple popup
    windows. Link1, for instance, opens 3 popup windows, the 2 first with images
    and other content and the 3rd with a link that should close all open popups. To
    achieve this I used the following functions:

    /*Array with popup window names*/
    var aPopupNames = new Array();

    /*Opens one popup*/
    function openPopup1 (sUrl, aNames, nWidth, nHeight, nLeft, nTop)
    {
    aNames.push (window.open (sUrl, '', 'left=' + nLeft + ',top=' + nTop +
    ',width=' + nWidth + ',height=' + nHeight));
    }

    /*Closes open popups*/
    function closePopups (aNames)
    {
    for (var i = 0; i < aNames.length; i++) {
    aNames[i].close()
    }
    }

    The function openPopup1 opens only one popup, but lets assume it opens more
    than one.
    So Link1 opens the 3 popup windows, and those popup window names are put into
    the aNames array. Now, I have tried using the closePopups function on a link on
    the main document and it worked, the popups close correctly. When I tried to
    use it in a link on the 3rd popup opened by Link1, though, it doesn't seem to
    recognize the aNames array, at least that's why I guess it doesn't work. I've
    only been working with javascript for a very short while, so I'm not aware of
    specific properties and functions that might solve this problem easily. I
    guessed there might be some sort of _parent property as in Flash actionscript,
    or some way to refer to the array defined in the main document, or to pass that
    array into the 3rd popup so it can be used.

    Can anyone help me with this, please? Hope it was clear enough, I'll be happy
    to clarify anything you need.

    Thank you in advance,

    Jo?o

    maguskrool Guest

  2. Similar Questions and Discussions

    1. Cannot create JavaScript popup menu with Show Popup Menuusing Add Behaviors
      Whenever I load a page with this added behavior and test it with my link, I get an "Error on Page" message. Here is what I am doing: Create a...
    2. Popup menu on popup window
      Hi, I want to create a popup menu when a button on a popup window is clicked. I have this in my popup window: myMenu =...
    3. When window closes
      When a user clicks the window close block/x in the top right corner I need to send the browser to a logout script page that logs them out and closes...
    4. popups advertising to stop popups
      Greetings -- Does the title bar of these pop-ups read "Messenger Service?" This particular "sales method" is strikingly similar to the...
    5. Brown popups offering to give programs to block popups
      are these genuine ads to protect windows xp owners or are they spyware ads. as they all sem to want to stop popups, but the most popups i get...
  3. #2

    Default Re: popup that closes itself and other popups

    Ok, after a bit of research I discovered the window.opener... It works now when I use

    href="javascript:window.opener.closePopups(window. opener.aNames)"

    on the link that closes the popups.
    maguskrool Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139