Web Analytics Made Easy -
StatCounter Check for Child window & close if open.. - CodingForum

Announcement

Collapse
No announcement yet.

Check for Child window & close if open..

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Check for Child window & close if open..

    There are 3 files involved with a process, 1 that gatheres files, 2'nd Processes files & the 3'rd is a file (results page) opened in a popup window from the 2'nd. When the popUp window is opened, the 2'nd page is replaced by the 1'st page, ready for the start of another process. But how do i check to see if the popUp window is there for when the user reaches the second page again.

    At the moment if the popUp window is open when another process is activated, the popUp window is not refreshed with the new results. I'd like to close the popUp window before opening it again.

  • #2
    one way to do it is to open it then close it right after.

    function closePopups() {
    var popUp=window.open("blank.htm","name of the popup window","width=1,height=1");
    popUp.close();
    }


    <BODY onLoad="closePopups()">

    by opening it again you get the window handle (if it exists) so you can close it.

    Comment


    • #3
      Re: Check for Child window &amp; close if open..

      Originally posted by Jodda
      At the moment if the popUp window is open when another process is activated, the popUp window is not refreshed with the new results. I'd like to close the popUp window before opening it again.
      how do you open the popup window from the 2nd file?
      Glenn
      vBulletin Mods That Rock!

      Comment


      • #4
        Hi,

        Open the results page, from page 2 like this:

        var CenW = (screen.width - 760) /2;
        var CenH = (screen.height - 480) /2;
        lWin=window.open("dl_onlineDemo_scanresults.asp","lWin","width=760,height=480,top="+CenH+",left="+Ce nW+",scrollbars=yes,resizable=yes");

        If you try and Alert(lWin) - comes back with 'undefined', so i tried an If>Else with 'undefined' and that returned an error too.

        Maybe its loosing the (popUp win) name and any recognition with the (popUp Win) when the opener page is unloaded?

        As an alternative i could create a boolean variable inside a session object with 'asp', then write the session var as a JS var, then do a check on the JS var to see if the popUp win is open, but i was sure JS would be able to do a check?

        Comment


        • #5
          This:

          lWin=window.open("dl_onlineDemo_scanresults.asp","lWin","width=760,height=480,top="+CenH+",left="+CenW+",scrollbars=yes,resizable=yes");

          ...should always open the "updated" page unless the asp page produce the same result in every instance.
          What factor would the asp page change its content?

          At the moment if the popUp window is open when another process is activated, the popUp window is not refreshed with the new results.
          Glenn
          vBulletin Mods That Rock!

          Comment


          • #6
            The asp page outputs a session var that holds html output from a .dll, i see where your going and your right, on the second time round, if the window is open, the asp page within the popUp window is not refreshed.

            On the second time around if i right-click --> Refresh, the content changes.

            Is there a refresh() command in JS?

            Comment


            • #7
              Are right, part of the location object, added this to the end of the code above and all is fine, cheers both:

              lWin.location.reload();
              lWin.focus();

              Comment

              Working...
              X