Click to See Complete Forum and Search --> : Close browser window w/frames by javascript:close()


markus
01-29-2003, 05:22 AM
Hello everybody,

I am fairly new to webdesign and especially to javascript.
I have made a webpage where I am using two frames to display the content. One frame is designated to the menu and the other frame is for the content of the webpage.
Here is my question: I have inserted a simple button into the menu-frame with the following link: javascript:close(), because I want to give the user the chance to close the entire browser window from within the webpage. But guess what it doesn't work!!!!

I got it to work on a webpage without frames, so the problem seems to be located in the frame aspect.

Can somebody tell me the trick????

Here is the link to the mentioned page: http://wedding.cimplexx.de/start-engl.htm

Charles
01-29-2003, 05:54 AM
<script type="text/javascript">
<!--
document.write('<a href="#">Close this window.</a>');
document.links[document.links.length-1].onclick = function () {top.close(); return false};
// -->
</script>

Or better yet:

<script type="text/javascript">
<!--
if (top.opener) {
document.write('<a href="#">Close this window.</a>');
document.links[document.links.length-1].onclick = function () {top.close(); return false};
}
// -->
</script>

markus
01-29-2003, 07:01 AM
Hello Charles,

thanks for the fast reply. I will check it out tonight when I get a chance.:)