View Full Version : a window.opener possible bug using IE 5.5
djche
10-30-2002, 05:15 PM
I am having a weird problem with window.opener.
The problem is that if I close the pop-up window, sometimes(but not everytime) the opener window closes too. The pop-up has a flash object that calls the window.opener method.
The code to open the window from the opener page is:
function newWindowC(URL) {
window.open(URL,'slidesWindow','width=740,height=480,toolbars=no,location=no,resizable=no');
}
the function call is
newWindowC('/slides/index.asp');
the code on the popup window using the window.opener method is:
function controlWindow(){
opener.document.location.href="../posttest.asp";
window.self.close();
}
the method from flashMX is
getURL("javascript:controlWindow();");
any ideas at all?
DJChe
ps. I already searched the actionscript forums and the flashMX forums for an answer.
RadarBob
10-30-2002, 07:34 PM
Just today I read that you cannot (should not?) ever say:
window.self.close()
"window" is a self reference, so it's ok to do the following, which is understood to mean this window:
window.close()
Also OK is:
self.close()
joh6nn
10-30-2002, 08:16 PM
RadarBob, where did you read that? and what reason did they list? i agree with the sentiment, for purely syntactical reasons, but in theory, there shouldn't be anything wrong with that.
beetle
10-30-2002, 08:39 PM
Originally posted by joh6nn
RadarBob, where did you read that? and what reason did they list? i agree with the sentiment, for purely syntactical reasons, but in theory, there shouldn't be anything wrong with that. Huh? :confused:
In a window with NO frames:
window == self == top == parent
So using window.self is like using self.self, or window.window, or self.window, or parent.top or....
You get the picture.
joh6nn
10-30-2002, 08:54 PM
right. and i'm saying, that's not something i would do, but, in theory, there's nothing wrong with it. so, i'm wondering what reason was given, as for why that shouldn't be done, in the article that RadarBob read.
RadarBob
10-30-2002, 09:33 PM
From Pure Javascript, third Edition
Because 'window' and 'self' are properties of the window object, you can't use both window and self in the same context. For example, the following code doesn't work:
window.self.document.write("<h1>Text.</h1>")
Finally, in multiframe environments, window and self always refer to the window in which the JavaScript code is executed.
djche
10-31-2002, 03:41 PM
Although that was valuable advice, it didn't answer my question. Thanks none the less.
DJChe
mordred
10-31-2002, 07:42 PM
Originally posted by djche
The problem is that if I close the pop-up window, sometimes(but not everytime) the opener window closes too. The pop-up has a flash object that calls the window.opener method.
Does the opener window close without a confirmation message? If so, then it's really a nasty thing.
function controlWindow(){
opener.document.location.href="../posttest.asp";
window.self.close();
}
Hmh. Apart from what RadarBob mentioned, the only thing I see here is that you use the deprecated document.location... better just use location.href = "urlstring";
Trying to access the "location" object through "document" is ehr... unusual. Perhaps IE tried to lookup object references for you in order to execute the code, but got confused with window references while doing this.
Note that the above diagnose might not solve your problems, there are various bugs in IE in regard to the opener property. It *generally* helps if you don't manipulate the opener's objects directly, but rather call a function in the opener document, like
// in popup window
function controlWindow(){
opener.changeURL("../posttest.asp");
window.close();
}
// in opener
function changeURL(url) {
location.href = url;
}
Perhaps that helps...
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.