Forum Moderators: open

Message Too Old, No Replies

parent.window.close() in Mozilla

Close parent window from within iframe using Mozilla

         

mrnoisy

3:06 am on Aug 20, 2003 (gmt 0)

10+ Year Member



I need to close the parent window from within an iframe. Using parent.window.close() works perfectly except in Mozilla and I haven't been able to find an alternative solution. Any ideas would be appreciated.

gph

3:21 am on Aug 20, 2003 (gmt 0)

10+ Year Member



I don't think it's possible. Try it then have a look at the JavaScript Console (Tools > Web Development)

Scripts may not close windows that were not opened by script.

I think you'd have to first open the parent from another window.

mrnoisy

3:39 am on Aug 20, 2003 (gmt 0)

10+ Year Member



Thanks for that, I'll keep trying.

draco

8:04 am on Aug 24, 2003 (gmt 0)

10+ Year Member



The script below closes a parent window, even if it hasn't been popped using Javascript.

However, although it works fine in Netscape v7, I find that it works erratically in IE6. It always shuts down the parent window, but often opens up multiple copies of the pop-up window. At least it does, when used in conjunction with my standard openpopup function.

If you can find the answer, I would be interested to hear from you. Note: index.htm is the name of the parent window.

[In child window]

if (!opener.closed && opener.location){
opener.location.href="index.htm";
opener.opener = top
opener.parent.window.close();
}

[In parent window]

function openpopup(){
var popurl="mainmenu.htm"
winpops=window.open(popurl,"","toolbar=no,location=no,directories=no,status=no,*
menubar=no,scrollbars=no,resizable=yes,copyhistory=yes,width=748,height=400")
}

* line break added to prevent side scroll

[edited by: tedster at 10:38 am (utc) on Aug. 24, 2003]

mrnoisy

9:26 am on Aug 25, 2003 (gmt 0)

10+ Year Member



parent.window.close() works fine in NN7, I want it to work in Mozilla. I haven't found a solution yet.