[Javascript] Detecting existence of windows

Mark Christie MChristie at avsgroup.com
Fri Nov 9 10:05:19 CST 2001


>What happens if you move window.close() below code for detecting if
>window.opener is open ?

That's the way I had coded it originally.  If I move window.close() at the
end of the function, then the window doesn't close at all.  The code dies as
soon as it hits the if(!window.opener.closed) line.

Regards,
   -Mark C.


-----Original Message-----
From: Mikael Lindström [mailto:mikael.lindstrom at nipsoft.se]
Sent: Friday, November 09, 2001 2:24 AM
To: javascript at LaTech.edu
Subject: RE: [Javascript] Detecting existence of windows


Oh well ... then I don't know, I'm not that good in JavaScript but I just
noticed something in your code.


> function updateconfirm() {
> 	alert('Your employee information has been updated!');

Here you close "your window"
> 	window.close();

Presuming window is not a variable set by you (rename it if so) you closes
down current window and by doing that you alsa end execution of code
therefore

while you try to contact it's opener using "your window" as a reference.
> 	if(!window.opener.closed()) {
> 		window.opener.location.reload();
> 		window.opener.focus();
> 	}
>
> }

it should never execute (at least what I now). On the other hand you claim
that i works in IE5.5 soo ...

What happens if you move window.close() below code for detecting if
window.opener is open ?


Like this:

> function updateconfirm() {
> 	alert('Your employee information has been updated!');
> 	if(!window.opener.closed()) {
> 		window.opener.location.reload();
> 		window.opener.focus();
> 	}
> 	window.close();


/Mikael

_______________________________________________
Javascript mailing list
Javascript at LaTech.edu
http://www.LaTech.edu/mailman/listinfo/javascript



More information about the Javascript mailing list