Welcome to Webmaster Resources 101


Our Network:

How To Hide A Frame With JavaScript

[ About This Author :: Request Reprint :: Print Article :: Tell A Friend ]

How To Hide A Frame With JavaScript

By Ben Sinclair
http://www.webmaster-resources101.com

This tutorial will teach you to hide a frame within a frameset.

1. First of all you need to add a name to your frameset so that the JavaScript can identify it:

<frameset cols="200,*" border="0" name="FrameName">
<frame name="left" src="left.php" target="right"></frame>
<frame name="right" src="right.php" target="_self"></frame>
</frameset>


Change FrameName to anything you wish.

2. Now you need to add this code inbetween the <head> tags in one of the <frame> pages:

<script language="JavaScript">
<!--
function HideFrame()
{
top.FrameName.cols = "0,*";
}
-->
</script>


Again change FrameName to whatever to named the frameset.

3. Last of all in the same document you added the JavaScript to, add a link like this:

<a href="#" onClick="javascript:HideFrame()" target="_self">Hide This Frame!</a>

That's it! Click the Hide Frame link and watch your frame disappear!

Enjoy!

 
Other Related Material:

Discuss this in our Webmaster Forums

About The Author:
Ben Sinclair
http://www.webmaster-resources101.com
Ben Sinclair is the Webmaster of [url=http://www.webmaster-resources101.com/]Webmaster Resources 101[/url] and [url=http://www.webmaster-forums101.com/]Webmaster Forums 101[/url].
Go To Top

This article has been read 3009 times.

[ About This Author :: Request Reprint :: Print Article :: Tell A Friend ]