473,386 Members | 1,712 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 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 7583
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: cirillo_curiosone | last post by:
Hi, i'm new to javascript. I started studing it on the web few weeks ago, but still haven't been able to solve one big problem: HOT TO PASS VALUES FROM A SCRIPT VARIABLE TO A CHILD HTML...
10
by: Tom Szabo | last post by:
Is there an event when that triggers when the window is closing.... I am talking about when the user clicks on the cross on the right top corner of the window!!!
5
by: Ron L | last post by:
I have an MDI application with a number of child windows. In each child window I am catching the Closing event and having the child window decide if it should set cancel to true. The intent here...
2
by: Ron L | last post by:
I have an MDI application which opens a number of child windows, each of which could have data in a state that needs to be saved. Each child window catches its Closing event and cancels it if the...
1
by: Chris Bruce | last post by:
In my application I need a way to distiguish between the following events: 1. When a user closes an MDI child window. 2. When the user closes the MDI parent window which subsequently closes the...
10
by: Charles Law | last post by:
For some reason, when I click the X to close my MDI parent form, the action appears to be re-directed to one of the MDI child forms, and the parent remains open. I am then unable to close the...
4
by: reemamg | last post by:
From a parent window a new child window is open with window.open <script type="text/javascript" language="JavaScript" > function abc() { if(window.event.clientY <0 &&...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.