471,049 Members | 1,602 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,049 software developers and data experts.

Closing HTML window from child frame

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

Dec 12 '06 #1
1 7315
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( ... );
--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Dec 12 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by cirillo_curiosone | last post: by
5 posts views Thread by Ron L | last post: by
1 post views Thread by Chris Bruce | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.