By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,504 Members | 1,092 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,504 IT Pros & Developers. It's quick & easy.

browsers' differences in action on same code.

P: n/a
This code works perfectly in IExplorer, but in exactly the same context
does not work at all in Netscape 7.x.

<SCRIPT TYPE="text/javascript" LANGUAGE="JavaScript">
<!--
if (window.parent.opener.closed)
{
window.parent.close();
};
// -->
</SCRIPT>

This is intended to detect the presence of an open parent window. When
one closes the open parent in IE, the child closes promply. In Netscape,
the inner loop is apparently not executed after the window is closed.
Reversing the logic on the opener test works fine as long as the window
is open. But, hey! Isn't ...opener.closed supposed to return something
if a window is closed? It seems to simply... fail. The inner loop will
not execute with either a negative or positive logic spin (!window...).

--
***********************************
* Bob Dickow (di****@uidaho.edu) *
* Hampton School of Music *
***********************************
Jul 20 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Robert Dickow wrote:
This code works perfectly in IExplorer,
Sure? Maybe you have disabled the display of script errors.
<SCRIPT TYPE="text/javascript" LANGUAGE="JavaScript">
<!--
if (window.parent.opener.closed)
{
window.parent.close();
};
// -->
</SCRIPT>

This is intended to detect the presence of an open parent window. When
one closes the open parent in IE, the child closes promply.
Where is the event that triggers the above code?
In Netscape, the inner loop is apparently not executed
There is no (`if') loop! `if' is a conditional statement
and you defined a block of statements with `{...}' to be
executed if it evaluates to `true'.
after the window is closed.


Try

function foobar()
{
if (window.parent
&& window.parent.close
&& (!window.parent.opener || window.parent.opener.closed))
window.parent.close();
}

and use the `unonload' event handler of the `body' element to call that
function. Note that the event also fires when the user displays another
document in the same window.
PointedEars

Jul 20 '05 #2

P: n/a
(Have canceled my other posting, please consider it obsolete.)

Robert Dickow wrote:
This code works perfectly in IExplorer,
Sure? Maybe you have disabled the display of script errors.
<SCRIPT TYPE="text/javascript" LANGUAGE="JavaScript">
<!--
if (window.parent.opener.closed)
{
window.parent.close();
};
// -->
</SCRIPT>

This is intended to detect the presence of an open parent window. When
one closes the open parent in IE, the child closes promply.
Where is the event that triggers the above code?
In Netscape, the inner loop is apparently not executed
There is no (`if') loop! `if' is a conditional statement
and you defined a block of statements with `{...}' to be
executed if it evaluates to `true'.
after the window is closed.


Try

function foobar()
{
if (window.parent
&& window.parent.close
&& !window.parent.closed
&& (!window.parent.opener || window.parent.opener.closed))
window.parent.close();
}

and use the `unonload' event handler of the `body' element to call that
function. Note that the event also fires when the user displays another
document in the same window.
PointedEars

Jul 20 '05 #3

P: n/a
"Robert Dickow" wrote on 11/11/2003:
This code works perfectly in IExplorer, but in exactly the same context does not work at all in Netscape 7.x.

<SCRIPT TYPE="text/javascript" LANGUAGE="JavaScript">
The 'language' attribute is depreciated in HTML and shouldn't be used.
You should also realise that "JavaScript" represents v1.0 of the
language. Netscape probably (read: double check with someone else)
interprets this religiously and neither 'opener' nor 'closed' were
introduced until v1.1.
<!--
if (window.parent.opener.closed)
{
window.parent.close();
};
// -->
</SCRIPT>

This is intended to detect the presence of an open parent window.
I don't believe it does:

window
current window
window.parent
parent of the current window
window.parent.opener
window that opened (using window.open) the parent of the current
window
window.parent.opener.closed
true if the window that opened (using window.open) the parent of the
current window is closed

Are you sure that you're checking the correct window? You describe the
parent, not the parent of the parent.
When
one closes the open parent in IE, the child closes promply. In Netscape, the inner loop is apparently not executed after the window is closed. Reversing the logic on the opener test works fine as long as the window is open. But, hey! Isn't ...opener.closed supposed to return something if a window is closed? It seems to simply... fail. The inner loop will not execute with either a negative or positive logic spin

(!window...).

Jul 20 '05 #4

P: n/a
Thanks for the solution! The wonderfully byzantine test clause
solved the problem for Netscape. Turns out that it does ok
with the deprecated LANGUAGE="JavaScript" in this case.

I don't use a trigger event for this at all; it is in the
midst of PHP code and it simply passed to the client
when a certain condition is present. This instantly closes
the client window.

Thomas 'PointedEars' Lahn <Po*********@web.de> wrote in
news:bo*************@ID-107532.news.uni-berlin.de:
Robert Dickow wrote:
This code works perfectly in IExplorer,


Sure? Maybe you have disabled the display of script errors.
<SCRIPT TYPE="text/javascript" LANGUAGE="JavaScript">
<!--
if (window.parent.opener.closed)
{
window.parent.close();
};
// -->
</SCRIPT>

This is intended to detect the presence of an open parent window.
When one closes the open parent in IE, the child closes promply.


Where is the event that triggers the above code?
In Netscape, the inner loop is apparently not executed


There is no (`if') loop! `if' is a conditional statement
and you defined a block of statements with `{...}' to be
executed if it evaluates to `true'.
after the window is closed.


Try

function foobar()
{
if (window.parent
&& window.parent.close
&& (!window.parent.opener || window.parent.opener.closed))
window.parent.close();
}

and use the `unonload' event handler of the `body' element to call
that <snip>


--
***********************************
* Bob Dickow (di****@uidaho.edu) *
* Hampton School of Music *
***********************************
Jul 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.