Forum Moderators: open

Message Too Old, No Replies

IE6 crash with onUnload="parent.window.opener.location.reload();"

onUnload="parent.window.opener.location.reload(true);"

         

coderdoc

4:31 am on Sep 6, 2004 (gmt 0)

10+ Year Member



I'm using a pop-up window to refresh the parent (opener) window when it's closed. The code is:

<body onUnload="parent.window.opener.location.reload(true);">

This code is in a page within a frameset in the pop-up window. Works perfectly on all but one Windows XP machine. On that machine IE6.0.2800... (very new browser) crashes when the pop-up is closed and Windows wants to send an error report. Mozilla works fine on the same machine. IE6 and older browsers work fine on every other machine tested.

Any ideas? Is there some setting in IE6 that I should look for on the machine that crashes, or is there a problem with the code, or is it possible that the browser is not backwards compatible with this code?

Any help is appreciated.

StupidScript

7:15 pm on Sep 7, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Did you try simply "opener.location.reload(true)"?

Also: opener.location.reload() (implied true)

and: opener.history.go(0) (GET from cache)

The framed doc that opened the popup IS the opener, regardless of its place in the parent window's DOM.

coderdoc

10:26 pm on Sep 7, 2004 (gmt 0)

10+ Year Member



StupidScript,

Thanks for the reply. I'm thinking along the same lines as you, that the script needs some tiny tweak to accommodate this latest version of IE. But I've tried all your suggested permutations of the code (and then some) with identical results (IE only crashes on the one machine and only at this one point). And no matter what reasonable sequence of methods and procedures I use (including all that you suggested), the code works on other machines with versions of IE6 that are only slightly older than the one that crashes?!?!?!?

I'm at a loss.

StupidScript

10:50 pm on Sep 7, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It almost sounds like a security problem. Is the XP browser that's crashing on a SP2 machine, or something? Anything to differentiate it from the other XP machines on which the code works?

coderdoc

11:38 pm on Sep 7, 2004 (gmt 0)

10+ Year Member



Well that seems to be the $64K question for which I have no answer. But, no, that machine is running XP Home and the SP2 update has not been installed. Curiously, that is also the only piece of code that it doesn't like.

Rambo Tribble

4:02 pm on Sep 8, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Just for fun, have you tried switching focus before invoking reload? Probably won't do anything differently, but what the heck, why not give it a try?

coderdoc

5:01 pm on Sep 8, 2004 (gmt 0)

10+ Year Member



Rambo Tribble,

No luck with that. You know the funny thing is that IE generates a Windows error alert asking if I want to send an error report, and then IE closes. Usually, when a script doesn't work, it just doesn't do the deed and you get nothing other than maybe an "Error on page" in the status bar.?

DrDoc

6:29 pm on Sep 8, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Are you opening a frameset in the pop-up window?
If so, try this:
top.opener.location.reload()

Or maybe IE crashes because the reference is lost when the window is closed?

StupidScript

8:11 pm on Sep 8, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



That sounds interesting, DrDoc. How could one get the script to be triggered before the child window closes if the event is body.onUnload?

If not for my belief that onunload is the final event, I might suggest something like this:

<script language="javascript" type="text/javascript">
function reloadMom() {
opener.location.reload(true);
// half-second delay then close child
setTimeout("self.close()",500);
}
</script>
<body onUnload="reloadMom()">

The problem with this, of course, is that the body unloads AS the window is closing, so there's no "self" to close by the end of the script.

If the user is clicking a BUTTON to close the window when done with whatever they are doing, you could use the button action to do the update before closing. If they use the little "x", though, you're in the same boat.

[edited by: StupidScript at 8:16 pm (utc) on Sep. 8, 2004]

coderdoc

8:11 pm on Sep 8, 2004 (gmt 0)

10+ Year Member



DrDoc,

I use this code in different types of pop-ups. Some of the pop-ups use framesets, others don't, and it doesn't seem to make any difference to the machine that crashes. Generally, the opener page is in a frameset as well. Also, with some of the pop-ups, other pages within the same frameset are capturing and sending data from/to a database, so that when the opener refreshes, the changes are displayed. The framed pop-up page with the opener.reload command is static, so its opener is truly in the window beneath the pop-up - I think. One may argue that the page containing the frameset is the true opener of the framed page but, again, this code works on all but one machine that we've tested. And referring to an opener of an opener (e.g. "parent.opener.opener.location.reload()") doesn't work.

I understand your point about lost reference using the onUnload method. Using onLoad, however, causes the focus to shift to the opener window prematurely. I could shift focus BACK to the pop-up, but that's too much action going on in front of the user (the pop-up disappears, the opener window refreshes, then the pop-up re-appears - all unprovoked from the user's standpoint). Is there another method that can make the opener refresh beneath without losing focus on the pop-up?

Rambo Tribble

10:27 pm on Sep 8, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I do recall someone in one of the forums finding that his onunload script wasn't completing execution after updating IE. Perhaps this is a variant of the same problem. For some reason, it appears that some newer versions of IE do, in fact, close the child window so fast the onunload scripts don't have time to finish.

The Windows error message, however, does make it sound as if the problem is rooted deeper than the JS interpreter.