Page 1 of 1

Close frame or open frame to whole window

Posted: Wed Feb 19, 2003 4:34 pm
by mcurry
I searched around and didn't find an answer for this. Basically I want a link in Frame A that when clicked either gets rid of Frame A or opens Frame B into the window. Thanks.

Posted: Wed Feb 19, 2003 4:57 pm
by volka
try target="_top" als property of the link

Posted: Wed Feb 19, 2003 5:14 pm
by mcurry
The problem is that I dont know exactly what the link is. Basically my site will be in the top frame and an external site will be in the bottom frame. So I want a way for the user to close the top frame and just have the external site. Initially I know the address of the external site, but the user may surf around and I dont want to reset them to the beginning.

Posted: Wed Feb 19, 2003 8:11 pm
by volka
maybe not exactly what you want, but you might minimize the frame

Code: Select all

<html>
<frameset rows="20%,*" id="idFrameset">
	<frame src="top.html" />
	<frame src="bottom.html" />
</frameset>
</html>
and top.html

Code: Select all

<html>
	<head><title>changing framesize</title>
		<script type="text/javascript">
			function minimizeFrame()
			&#123;
				w = window.parent.document.getElementById("idFrameset");
				if (w != null)
					w.rows="0,*";
			&#125;
		</script>
	</head>
	<body>
		<button onClick="javascript:minimizeFrame()">minimize</button>
	</body>
</html>

Posted: Thu Feb 20, 2003 8:56 am
by mcurry
Interesting solution. Not exactly what I had in mind. I would still love a way to completely remove the frameset, but I'm starting to think that isnt possible.

Posted: Fri Feb 21, 2003 10:56 am
by cwcollins
Here ya go!

Code: Select all

<a href=# onClick="Javascript:top.location.href=top.content.location.href;" >Break out of frames</a>
Should work!

c.collins

Posted: Fri Feb 21, 2003 8:10 pm
by volka
I thought of that first, too. But what about POST-data of the frame content (if there is any) ?

Posted: Fri Feb 21, 2003 8:51 pm
by Skyzyx
Insert this into your top frame, and attach it to a link or onclick event:

Code: Select all

<script language="JavaScript" type="text/javascript">
function changePage()
&#123;
	if (self.parent.frames.length != 0)
	&#123;
		self.parent.location=self.parent.frames&#1111;1].location.href;
	&#125;
&#125;
</script>
About post-content, you can always re-send it. Browsers normally give you the option. I've tested this script in IE 4, 5, 6, NS4, NS6, NS7, Opera6, Opera7, pretty much any Gecko browser, and the script is so simple it should even work as far back as Netscape 2 and IE 3...

Posted: Sat Feb 22, 2003 10:13 am
by mcurry
Skyzyx wrote:Insert this into your top frame, and attach it to a link or onclick event:

Code: Select all

<script language="JavaScript" type="text/javascript">
function changePage()
&#123;
	if (self.parent.frames.length != 0)
	&#123;
		self.parent.location=self.parent.frames&#1111;1].location.href;
	&#125;
&#125;
</script>
About post-content, you can always re-send it. Browsers normally give you the option. I've tested this script in IE 4, 5, 6, NS4, NS6, NS7, Opera6, Opera7, pretty much any Gecko browser, and the script is so simple it should even work as far back as Netscape 2 and IE 3...
This script only works if both sites are from the same domain, right? This gives me a permission denied error, because the frame I'm trying to maximize is from an external domain.

Posted: Sat Feb 22, 2003 12:46 pm
by Skyzyx
Eh, I forgot about that whole domain thing. If the domain thing is getting in the way, it means that the browser won't let you do it. Sorry...