Closing HTML window from child frame

J

jd

Hi guys, I'm trying to create an HTML page that contains two frames.
The bottom frame should simply be some website, but the top frame needs
to have a close link to kill the window. I tried calling
'document.window.close()' from the child frame, but without success. I
then tried putting the 'close()' call in the parent page and calling it
from the child, but still without success.

Can anyone take a look at the HTML/Javascript below and let me know
where I'm going wrong?

* * * * PARENT.HTML * * * *

<HTML>
<HEAD>
<TITLE>Parent page</TITLE>
</HEAD>
<SCRIPT LANGUAGE="javascript">
function doClose() {
alert('I have been called!');
document.window.close();
}
</SCRIPT>
<FRAMESET ROWS="5%,95%">
<FRAME SRC="child.html">
<FRAME SRC="http://news.bbc.co.uk">
</FRAMESET>
</HTML>

* * * * CHILD.HTML * * * *

<HTML>
<HEAD>
<TITLE>Child frame</TITLE>
</HEAD>
<BODY>
<P ALIGN="RIGHT">
<A HREF="javascript:parent.doClose();">
<B>
<BIG> [ CLOSE WINDOW ] </BIG>
</B>
</A>
</P>
</BODY>
</HTML>

* * * * END * * * *

Many thanks in advance
 
A

ASM

jd a écrit :
Hi guys, I'm trying to create an HTML page that contains two frames.
The bottom frame should simply be some website, but the top frame needs
to have a close link to kill the window.

It is formely forbiden to close a window by JS it she hasn't been
previously opened by JS

You haven't to search longer : you can't.

However, if your framed page has been displayed in a popup window
(exclusively via Javascript) you can try :

parent.opener.truc.close();

where 'truc' is the JS name of popup

JS name :
truc = window.open( ... );
 

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

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,222
Members
46,809
Latest member
moe77

Latest Threads

Top