Click to See Complete Forum and Search --> : close button in window with frames


Ambrrose
02-19-2003, 12:57 PM
I have a web page in fullscreen mode with frames. How can I make a close button (that forces the whole window with all the frames to close) and where should I put it?
How does the close window command work with frames anyway?

THAAAAAANKS

pyro
02-19-2003, 01:02 PM
To close the entire frameset, use top.close();. NOTE: unless your frameset was opened with javascript, it will ask if you want to close the window. This is a security feature, and can't be avoided...

Ambrrose
02-19-2003, 01:07 PM
Where should I put it?

pyro
02-19-2003, 01:11 PM
I would do it something like this.

This goes in your <head><script language="javascript" type="text/javascript">
function closewin()
{
top.close();
}
</script>

and then add this to somewhere in your body...<a href="#" onClick="closewin();">Close This Window</a>

Charles
02-19-2003, 03:07 PM
Considering that one in ten times JavaScript will not work, you might want to use this method which will only present the link if it is going to work.

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