PDA

View Full Version : window.opener failing if opener is closed.


elcaro2k
10-28-2002, 02:28 PM
I am using the following function in my app:

function callapprwdw() {

if (window.opener!=null) {
self.blur();
window.opener.focus();
}else if (window.opener==null) {
document.getElementById("anchNxt").href="./NextMember.asp";
}
}

If the opening window is closed the app blows up? Shouldn't the window.opener != null return true if the opener has been closed?

RadarBob
10-28-2002, 02:38 PM
Try this to test if the parent is open:

if (typeof window.opener != 'undefined') {
// it's alive! it's alive!;
}else{
//another one bites the dust
}


Uh.. not 110% positive one can check for the parent using this reference. Off hand I don't see why not.

I use this "typeof" checking technique in some cleanup code to make sure all my child windows are closed.

elcaro2k
10-28-2002, 02:50 PM
I am still getting this error message. see attachment

RadarBob
10-28-2002, 03:16 PM
document.getElementById("anchNxt").href="what's this?-->.<---/NextMember.asp";


that period. Is that correct?

brothercake
10-28-2002, 03:20 PM
You should also check for the "closed" property:

if(window.opener && !window.opener.closed) {

elcaro2k
10-28-2002, 03:33 PM
THANKS!!!! The window.opener.closed fixed it.

Bob, the period in ./file_name just indicates the current directory. I don't think that is causing a problem.

Thanks again guys!!!