Introduction
When they first came out, frames were
used almost anywhere, sometimes regardless of their importance; until
webmasters started to think of ways to use or ignore them.
Frames are used to divide your web screen in different parts that can
each behave independently. For example, one part of the screen could
display and change data regardless of what the other
screen(s) is (are) displaying. You can also make different frames
depend on each other.
Frame Structure
By default, frames are not parts of the
body of an HTML page. Therefore, they don't require a <body> tag.
Frames are arranged in columns and rows, and that's how you define their
layout. Since frames are independent, each requires its own file. And
each frame should have a name that will distinguish it from the other
frames. To occupy a frame, you tell the browser what file should load in
what frame. Therefore, there are two pieces of information the browser
needs from you: a name for the frame and which file you want displayed
in that frame. The name of the frame is given as an HTML classic file
and the name of the frame is considered a target.
The word "target" anticipates a "goal" for the file, this means "where the file will be displayed".
To create frames on a page, first declare a <frameset> tag, define
each needed frame inside of a frameset using the <frame> tag,
then close the frameset with the </frameset> tag. You define each
frame by providing the width and/or the height of frames to control
their dimensions. The width or the height is specified in pixels or by
percentage.
We will first create the files necessary for this lesson.
Practical Learning: Creating Frames
|
|
-
Start your text editor.
-
In your text editor, type:
<html>
<head>
</head>
<body bgcolor="#cc6500">
<font color="white"><b>Top Frame</b></font>
</body>
</html>
|
-
On the main menu of your text editor, click File -> Save As…
-
In the Save As dialog box, click the arrow of the Save In combo box and select Desktop.
-
On the toolbar of the Save As dialog box, click the Create New Folder button
-
Type Frames and click OK
-
Click the arrow of the Save As Type combo box and select All Files(*)
-
In the File Name box, type top.htm
-
Click Save.
-
Back in your text editor, change the file with the following:
<html>
<head>
</head>
<body bgcolor="#99ccff">
Left
</body>
</html>
|
-
On the main menu, click File -> Save As…
-
In the File Name, type left.htm
-
Make sure the Frames folder is displaying in the Save In combo box and click Save.
-
Change the content of the file as follows:
<html>
<head>
</head>
<body bgcolor="#ffcc99">
<center>Bottom</center>
</body>
</html>
|
-
Save the file as bottom.htm
in the Frames folder
-
Change the file as follows:
<html>
<head>
</head>
<body bgcolor="#33cc33">
Right
</body>
</html>
|
-
Save the file as right.htm
in the Frames folder.
-
Change the file's content as follows:
<html>
<head>
</head>
<body>
<center><font face="Wingdings,
Wingding, Times New Roman" size="7" color="#0000ff">{ &
{</font> <font face="Westminster,
Helvetica, Verdana" size="7">Main Area</font></center>
</body>
</html>
|
-
Save the file as main.htm
in the Frames folder.
-
Two-Frames: At its basic layout, you can have a
screen made of two frames. To get two vertical frames, you define a page
as having two columns. Here is an example of a screen divided in two
vertical frames:
<html>
<head>
<title>A Two-Frame Page</title>
<head>
<frameset cols="15%,75%">
<frame src="file1.htm" name="leftframe">
<frame src="file2.htm" name="rightframe">
</frameset>
</html>
|
|
-
Here is an example of a two horizontally framed page:
<html>
<head>
<title>A Two-Frame Page</title>
<head>
<frameset rows="15%,75%">
<frame src="file1.htm" name="topframe">
<frame src="file2.htm" name="bottomframe">
</frameset>
</html>
|
|
-
In your text editor, change the file content to:
<html>
<head>
<title>Frame Samples</title>
</head>
<frameset cols="100,*">
<frame name="top" src="top.htm">
<frame name="main" src="main.htm">
</frameset>
</html>
|
|
-
Save the file as frame1.htm
-
On the desktop, double-click the Frames folder icon.
-
Inside of the Frames window, double-click frame1.htm to preview the file
Maximize Internet Explorer if necessary.
-
Bring back your text editor and change its content with:
<html>
<head>
<title>Frame Samples 2</title>
</head>
<frameset rows="60,*">
<frame name="leftframe" src="left.htm">
<frame name="rightframe" src="right.htm">
</frameset>
</html>
|
|
-
Save the file as frame2.htm
-
Click Internet Explorer on the Taskbar.
-
On the main menu, click File -> Open…
-
In the Open dialog, locate the Frames window and click frame2.htm
-
Click Open and click OK
-
Bring back your text editor and change its content as follows:
<html>
<head>
<title>Frame Samples</title>
</head>
<frameset cols="12%,*">
<frame name="leftframe" src="left.htm">
<frameset rows="14%,*">
<frame name="topframe" src="top.htm">
<frame name="rightframe" src="right.htm">
</frameset>
</frameset>
</html>
|
|
-
Save the file as frame3.htm
-
Preview it in the browser and get back the your text editor.
-
Change its listing to:
<html>
<head>
<title>Frame Samples</title>
</head>
<frameset rows="12%,*">
<frame name="topframe" src="top.htm">
<frameset cols="14%,*,14%">
<frame name="leftframe" src="left.htm">
<frame name="mainframe" src="main.htm">
<frame name="rightframe" src="right.htm">
</frameset>
</frameset>
</html>
|
|
-
Save the file as frame4.htm
-
Preview it and get back to your text editor
-
Change its content to:
<html>
<head>
<title>Frame Samples</title>
</head>
<frameset cols="12%,*">
<frame name="leftframe" src="left.htm">
<frameset rows="14%,*,12%">
<frame name="topframe" src="top.htm">
<frame name="mainframe" src="main.htm">
<frame name="bottomframe" src="bottom.htm">
</frameset>
</frameset>
</html>
|
|
-
Save the file as frame5.htm
-
Preview it and get back to your text editor
-
Change its content to:
<html>
<head>
<title>Frame Samples</title>
</head>
<frameset cols="12%,*,12%">
<frame name="leftframe" src="left.htm">
<frameset rows="14%,*,12%">
<frame name="topframe" src="top.htm">
<frame name="mainframe" src="main.htm">
<frame name="bottomframe" src="bottom.htm">
</frameset>
<frame name="rightframe" src="right.htm">
</frameset>
</html>
|
|
-
Save the file as frame6.htm
-
Preview it and get back to your text editor
-
Change its content to:
<html>
<head>
<title>Frame Samples</title>
</head>
<frameset rows="12%,*,12%">
<frame name="topframe" src="top.htm">
<frameset cols="14%,*,14%">
<frame name="leftframe" src="left.html">
<frame name="mainframe" src="main.htm">
<frame name="rightframe" src="right.htm">
</frameset>
<frame name="bottomframe" src="bottom.htm">
</frameset>
</html>
|
|
|
No comments:
Post a Comment