Close frame or open frame to whole window

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
mcurry
Forum Newbie
Posts: 12
Joined: Tue Jan 21, 2003 3:41 pm

Close frame or open frame to whole window

Post 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.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

try target="_top" als property of the link
mcurry
Forum Newbie
Posts: 12
Joined: Tue Jan 21, 2003 3:41 pm

Post 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.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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>
mcurry
Forum Newbie
Posts: 12
Joined: Tue Jan 21, 2003 3:41 pm

Post 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.
User avatar
cwcollins
Forum Commoner
Posts: 79
Joined: Thu May 16, 2002 3:51 pm
Location: Milwaukee, WI, USA

Post 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
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

I thought of that first, too. But what about POST-data of the frame content (if there is any) ?
Skyzyx
Forum Commoner
Posts: 42
Joined: Fri Feb 14, 2003 1:53 am
Location: San Jose, CA

Post 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...
mcurry
Forum Newbie
Posts: 12
Joined: Tue Jan 21, 2003 3:41 pm

Post 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.
Skyzyx
Forum Commoner
Posts: 42
Joined: Fri Feb 14, 2003 1:53 am
Location: San Jose, CA

Post 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...
Post Reply