Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

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

Participant ,
Feb 24, 2009 Feb 24, 2009
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.

:-}
Len

(Code follows)

Note: "window.opener.location" is an object that contains the full URL including all of the original URL paramters.
TOPICS
Advanced techniques
3.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 25, 2009 Feb 25, 2009
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.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Feb 25, 2009 Feb 25, 2009
LATEST
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.

:-}
Len
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources