browsers' differences in action on same code.

R

Robert Dickow

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...).
 
T

Thomas 'PointedEars' Lahn

Robert said:
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
 
T

Thomas 'PointedEars' Lahn

(Have canceled my other posting, please consider it obsolete.)

Robert said:
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
 
M

Michael Winter

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...).
 
R

Robert Dickow

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top