Read + Write + Report
Home | Start a blog | About Orble | FAQ | Sites | Writers | Advertise | My Orble | Login

Html tute 6: Frames

July 31st 2006 01:05
Today I'm going to deal with frames. Frames are a controversial part of HTML web design, with many people feeling that they aren't a good design mechanism. However, I'll show you how to use them and then you can judge for yourself.

Frames divide the page into different sections. One major use for this is allowing you to have a menu down the left hand side and clicking on the options changes what is on the right hand side.

The first tag I will introduce is the frameset tag, which takes the following form.

<frameset division="something%, something%>

If you want to divide the page into two columns, each of which takes up 50% of the page you would write:


<frameset cols="50%,50%>

On the other hand if you wanted two rows you would type:

<frameset rows="50%,50%>

Either of these pieces of code will create two frames, but it wont add any content to either.

To add content to a frameset you use the: <frame src> tag. Your first use of this tag will define the contents of the first frame, and the second use will define the contents of the second frame (and so on).

This tag takes the following form:

<frame src="webpage.html">

As always, if the frames contents is in the same directory as webpage then you can just write the webpage name, but if it isn't you have to provide the whole URL.

So, lets create a new website, which we will call frames.html

Add the following code to it:

<html>
<head>
<title>Frames demonstration</title>
</head>
<frameset cols="25%,75%">
<frame src="lesson3.html">
<frame src="lesson4.html">
</frameset>

</html>

Note that the frameset tag is also closed by the </frameset> tag at the end.

Now, the next thing we'll do is make it so that when you click on a link in the left frame it opens it in the right one.

To do this we first need to give our right hand frame a name. So lets call it display. We do this with the following code:

<frame src="lesson4.html" name="display">

Now, we need to open lesson3.html and change the code below:

<a href="lesson1.html">This is the first lesson we learned</a><br>
<a href="lesson2.html">This is the second lesson we learned</a><br>
<a href="http://www.google.com">This is a link to Google</a>
<br>
<a href="extra.html">This links to the extra website</a><br>
<a href="extra.html#second">This takes us straight to the second part of extra</a>

To each link here we add the following code:

target="targetframe"

So the first link would become:

<a href="lesson1.html" target="display">This is the first lesson we learned</a><br>

Do this for all the links.

So lesson3.html would now look like:

<html>
<head>
<title>Lesson 3</title>
<head>
<body>
<a href="lesson1.html" target="display">>This is the first lesson we learned</a><br>
<a href="lesson2.html" target="display">>This is the second lesson we learned</a><br>
<a href=http://www.google.com target="display">>This is a link to Google</a>
<br>
<a href="extra.html" target="display">>This links to the extra website</a><br>
<a href="extra.html#second" target="display">>This takes us straight to the second part of extra</a>
</body>
</html>

Now, going back to our frames page we will try a few more things. Firstly, the use of the <noframes> tag.

This tag takes the following form.

<noframes>
<body>Message<body>
</noframes>

The purpose of this tag is to provide an alternative page for people whose browsers do not display frames. So, we will add:

<noframes>
<body>This webpage requires frames<body>
</noframes>

To our frames page. So, in its final form our frames page should look as follows:

<html>
<head>
<title>Frames demonstration</title>
</head>
<frameset cols="25%,75%">
<frame src="lesson3.html">
<frame src="lesson4.html" name="display">
<noframes>
<body>This webpage requires frames<body>
</noframes>
</frameset>
</html>

Hope you found this useful.

Adam
130
Vote
Shared on


   
Subscribe to this blog 


Just this blog This blog and DailyOrble (recommended)

   

   

   


Comments
2 Comments. [ Add A Comment ]

Comment by Cibbuano

July 31st 2006 01:48
for a while, frames were on all the pages, but I haven't seen a page with frames for a long time...

Add A Comment

To create a fully formatted comment please click here.


CLICK HERE TO LOGIN | CLICK HERE TO REGISTER

Name or Orble Tag
Home Page (optional)
Comments
Bold Italic Underline Strikethrough Separator Left Center Right Separator Quote Insert Link Insert Email
Notify me of replies
Notify extra people about this comment
Is this a private comment?
List the Email Addresses or Orble Tags of the people you would like to be notified about this comment


One per line max of 30

List the Email Addresses or Orble Tags of the people you would like to be notified about this private comment thread. Only the people in this list will be able to see or reply to your comment.


One per line max of 30

Your Name
(for the email going out to the above list, it can be different to your Orble Tag)
Your Email Address
(optional)
(required for reply notification)
Submit
More Posts
1 Posts
6 Posts
7 Posts dating from July 2006
Email Subscription
Receive e-mail notifications of new posts on this blog:
0
Moderated by Blog Cemetery
Copyright © 2006 2007 2008 On Topic Media PTY LTD. All Rights Reserved. Design by Vimu.com.
On Topic Media ZPages: Sydney |  Melbourne |  Brisbane |  London |  Birmingham |  Leeds     [ Advertise ] [ Contact Us ] [ Privacy Policy ]