2 Replies Latest reply on Feb 25, 2009 8:34 AM by PHRED-SE

    window.opener.location.replace(xxx) - does not always work

    PHRED-SE Level 1
      I open a PopUp window from my main page using a JavaScript “open.” I can do several things from this PopUp. When I am done with whatever I need to do on the PopUP, I close it. In the <body> of this page I have embedded a simple onUnload statement that refreshes the calling page so that I can automatically show changes that were made while on the PopUp.

      This code has worked successfully for a number of months on my development server as well as our production server. We recently moved the code to a client's server where it doesn't work. When the client clicks on the close button, the PopUp does not close. I believer it is because the onUnload code does not work and this error halts the close process.

      I have searched the web and have found several folks who are using similar code, but there is no reference so similar behavior.

      Since the PopUp is popping up and seems to be working correctly, I have to believe that all the IE settings are correct. There has been no mention of a JavaScript error message, so I'm thinking that they must have these error features turned off. I've requested that they turn them on, but it may be a day or two before I get an answer back from the client.

      I've reviewed all my JavaScript books and can find nothing that would indicate that this code is temperamental, or needs anything special.

      So here is my question: Does anyone out there know of any quirks that would cause this line of code from working.

      Server Systems: Windows 2003 or greater
      CF: CF8
      Clients: Windows XP Pro or Vista
      SQLServer 2005
      Required Browser: IE 6+ (most users have IE 7+)

      Thanks in advance for your help/suggestions with this mystery.


      (Code follows)

      Note: "window.opener.location" is an object that contains the full URL including all of the original URL paramters.
        • 1. Re: window.opener.location.replace(xxx) - does not always work
          Dan Bracuk Level 5
          js debugging is one of my least favourite activities. To find out at what poing it is going wrong, my approach would be:

          First, open an alert on the body onUnload event.

          If that works, do a simple reload of the parent page.

          If that works, I'm not sure.
          • 2. Re: window.opener.location.replace(xxx) - does not always work
            PHRED-SE Level 1
            Thanks for the idea.

            In one of the many, many results I got back last night when I Googled "window.opener.location", there was a discussion about " ...location" returns an object not a string but that it will act like a string on most occasions. I think that "window.opener.location.replace(xxx)" really wants xxx to be a string version of the URL. This kind of flew right by me last night. So today I updated the onUnload to: <body onUnload="window.opener.location.replace(window.opener.location.toString());">. Like before, this works just find on my development system.

            I've sent my customer service team this new version along with a test version that has an alert box in it; i.e., <body onLoad="alert(window.opener.location.toString()); onUnload="window.opener.location.replace(window.opener.location.toString());">.

            If the new real change doesn't work for the customer, then they can put the test file in place and capture the result of the alert so I can see what's up with that. What the alert box should show is the exact URL string that is in the address bar of the page I'm trying to refresh with the ...Replace()) funciton.

            Thanks again for your suggestion.