PDA

View Full Version : closing window with frames


bbispo
05-22-2003, 10:26 PM
Hi i have a window with 2 frames, one on top and the other below. I have a button in the page loaded in the frame below and i want to when i press that button, the browser window closes.

Ive tried window.close(); document.close(),close() and stil havent had success

Any ideas?

sage45
05-22-2003, 10:53 PM
If you want the current browser to close from the frame try:

top.close()

-sage-

Mr J
05-22-2003, 10:54 PM
Here's something to try:

Copy the following into a page and save it as closeme.htm in the folder where your bottom frame page is.



<HTML>
<HEAD>
<TITLE>Document Title</TITLE>
</HEAD>
<BODY>
<script language=JavaScript type=text/JavaScript>
<!--
window.opener = top;
setTimeout("self.close()",50)
// -->
</script>
</BODY>
</HTML>



In your bottom frame page copy the following


<form>
<input type="button" value="Close" onclick="parent.location='closeme.htm'">
</form>

Mr J
05-23-2003, 08:19 PM
I have done a bit of experimenting since my last reply and find the following script works.

Close frameset from within a frame

In the frame closing the frameset.

<script language=JavaScript type=text/JavaScript>
<!--
function close_all(){
parent.opener = top
parent.close()
}
// -- >
</script>

Use an event to call close_all()

Kylena
11-19-2003, 06:32 AM
Thank Mr J! I was looking for something to close my frame window without success when I found this! :thumbsup:

parent.close()