[Javascript] Detecting existence of windows

Mikael Lindström mikael.lindstrom at nipsoft.se
Fri Nov 9 02:24:05 CST 2001


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




More information about the Javascript mailing list