Click to See Complete Forum and Search --> : self.close() problems
Hooman
05-22-2003, 02:12 PM
function A in Parent is calling function B in the child....
Then parent would like to disappear right after that...
parent has 3 frames in it.
The 'button' which is running function A, is located in one of those 3 frames.
I tried:
self.close();
setTimeout("self.close()",1000);
I also tried closing the prent from the child, by:
opener.close();
self.opener.close();
None of these closes the parent...
Any suggestions?
Thanks
Vladdy
05-22-2003, 02:37 PM
Do not use popups and do not use frames. Your page should be designed to work without either.
Close frameset from within a frame
If you use parent.close() to close the frameset you might get the error message:
The webpage you are viewing is trying to close the window.
Do you want to close this window?
The following script will suppress this error message and close the frameset
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()
Close frameset from a popup
In the popup page.
<script language=JavaScript type=text/JavaScript>
<!--
function close_frameset(){
opener.parent.opener = top
opener.parent.close()
}
window.onerror=sh
function sh(){
return true
}
onload=close_frameset
// -- >
</script>
redsand198
06-05-2003, 09:43 AM
MR J-
could you help me integrate that code into my html?
here is what i have:
<tr>
<td width="100%"><font face="Bookman Old Style" size="2" color="#FF0000">
<a hr*ef="javascript:top.wind*ow.close()" style="text-decoration: none">Exit</a>
</font>
</td>
</tr>
i used asterisks because i'm not sure if this board messes with your code when you submit
the above code is part of a menu page which is one of three frames on my site.
i am also trying to close the entire browser application with out having the enduser see the yes/no security prompt
TIA
There are 2 ways this can be implemented
1)
Copying the following script into the HEAD section of the page containing the link that opens the popup.
<script language=JavaScript type=text/JavaScript>
<!--
function close_frameset(){
parent.opener = top
parent.close()
}
window.onerror=sh
function sh(){
return true
}
//onload=close_frameset
// -- >
</script>
And include close_frameset() in the link that opens the popup
OR
2)
Copy the following script into the HEAD section of the page that is loaded into the popup.
<script language=JavaScript type=text/JavaScript>
<!--
function close_frameset(){
opener.parent.opener = top
opener.parent.close()
}
window.onerror=sh
function sh(){
return true
}
onload=close_frameset
// -- >
</script>
The function runs onload and closes the frameset
redsand198
06-05-2003, 02:06 PM
i don't know if this matters at all, but i'm not intending to use popups at all. all i want to do it be able to click "exit" and have the browser close without the yes/no windows prompt
ok, so now my code looks like this:
<tr>
<td width="100%"><font face="Bookman Old Style" size="2" color="#FF0000">
<a href="" onClick=close_all()" style="text-decoration: none">Exit</a>
</font>
</td>
</tr>
with this in the header:
<html>
<head>
<script language=JavaScript type=text/JavaScript>
<!--
function close_frameset(){
parent.opener = top
parent.close()
}
window.onerror=sh
function sh(){
return true
}
//onload=close_frameset
// -- >
</script>
<title>CD Business Card</title>
</head>
so my page looks like this:
http://www.antachmotorsports.com/scr.gif
but when i click exit, it goes to this:
http://www.antachmotorsports.com/scr2.gif
so that obviously not what i want it to do because a.) the window wasnt closed and b.) it opened the list of files in the folder i am using in the framed window
thank you very much for all your help, i feel like im so close..
You have left the link location empty, and you are not calling function close_frameset() try the following
<a href="#null" onClick=close_frameset()" style="text-decoration: none">Exit</a>
redsand198
06-05-2003, 02:22 PM
thank you very much Mr J, i got it to work with help from another messageboard. here is what i did to make it work:
in the head:
<html>
<head>
<script language="JavaScript">
function close_all(){
parent.opener = top
parent.close()
}
</script>
the event:
<tr>
<td width="100%"><font face="Bookman Old Style" size="2" color="#FF0000">
<a href="" onClick="close_all()" style="text-decoration: none">Exit</a>
</font>
</td>
</tr>
:thumbup:
Like I said, you were not calling the correct function
:D