| [Index of Lessons] [Advanced Lesson 8] [Advanced Lesson 10] | A9. Frames |
| Frames Frames are a method of dividing a page into separate sections. The code behind frames is actually quite simple. The concept goes like this:
|
|||||||
| So it logically looks like :
|
|||||||
|
|||||||
| With Frame Page being in the background and Pages
1 and 2 are the only pages that a user sees when they load that Page. Frame Page is
the page that gets accessed by the browser, so it normally ends up being
the index/start/main page of a web site. There are only two main frame tags to contend with: <frameset> and <frame>. Now it's time to make use of this piece of knowledge, remember a frame based site can look either good or bad, my advice don't have more than 4 frames to a page. And only 4 if one is small and is out of the way.
Now frames are a lot different to explain with examples the way I have
been showing you, so this is what is going to happen, you will have to
make some new files (the code for all of these will be shown below)and
to return to this page you will have to use the back button on your
browser. Make a new page with the following code in it
<html> Notice that there is no <body> tags, this is because the frameset tags replace them. Now lets decide on how many frames we want shown. Lets work with two to start with. The code for this is :
<html> Now this still doesn't do much, but it does inform the browser to split the page into 2 coloumns that take up 50% of the page. You can also do this with rows. The code for this is:
<html> This is just the same as above except that the page is split into rows, instead of columns. It's time to add some actual pages to the frames. First we'll have to make them, we'll make small pages that only load a single word. This is just so you can get an idea on how these frames will work. Here is the code for the two pages that we will use as examples :
First they will be loaded as columns :
<html> Click here (Frames Example 1) to view these pages loaded. Remember to use the back button to return here. First they will be loaded as columns :
<html> Click here (Frames Example 2) to view these pages loaded. Remember to use the back button to return here.
The <framset> tag does all the dividing. It specifies a few things
regarding how to divide them up. It is quite possible to load up more than
2 pages as frames. Just remember to specify a page for each section of the
browser. It's obvious that the frames can be made in differents sizes.
Just ensure that the arithmetic used to calculate the percentage of each
frame is correct or the browser will come up with its own interpretation.
Relative Frame Sizing
|
|
Okay, now lets make a few more simple pages so we can start incorporating
some different techniques. The 2 new pages are :
Save them as rob.htm and fla.htm.
Now, we do the same with rows, change the frameset line to :
Now, let's get technical. You have seen basic columns and basic rows, now
lets make a page which has two columns on it and two rows. For this, you'll
have to edit your frame page so it matches the following : This way you should have a page that loads like this (Frame Example 5) page. Note how the first frameset still has 3 columns listed. This is because you are still have three columns, it's just that one of them is divided into rows.
|
| Frame Pictures Frames can also be used to load up an image. By having an image as a separate frame you can speed up the loading of other frames, especially if the image normally appears on all other pages. Such as a company logo, a standard banner or an image menu system. It's time to go through the steps in making an image frame.
Step 1
Step 2
Step 3
Step 4
Step 5
Step 6
Frame Border Tips 1
Frame Border Tips 2
Frame Border Tips 3
Frame Border Tips 4
Now that all of this has been firmly understood, it's time to make frames useful, this is done by adding links. Links are what make a web site work.
|
| Frame Links 1 We will skip back to two frames and the code for that is below. First thing will be adding a link from the frame Batman (file is bats.htm) to Robin (file is rob.htm). This is the easiest link there is and works by adding a link to the Batman. So what you should end up is with your main frame containing the Frames Page code and the Batman file containing the code displayed under the title Frame 1 :
In case you are wondering, I'll call this file bats1.htm for my reference.
Take a look at the new file here (Bats1.htm)
and now use this new page with the code shown above to produce the following
page( Frame Links 1).
Frame Links 2
In case you are wondering, I'll call this file bats2.htm for my reference. Take a look at the new file here (Bats2.htm) and now use this new page with the code shown above to produce the following page( Frame Links 2).
This is, the standard way of using frames. To have a link from your site
to an outside page is the exact same as a normal link except that you add
the target="window" part to the link. Just a note, the target does not have
to be called window, it could have been called fred, or anything else that
pops into mind. But that is beside the point.
Notice that _top loaded the Robin file to the whole browser screen. This is the most important attribute to have when loading outside links. Next is _blank. The code used is :
Notice that _blank gave the Robin file a new browser screen. Sometimes this is useful, but when surfing, too many of these forms of links and the user might have his browser crash because of the amount of memory all of the new browser windows take up. Next is _self. The code used is :
Notice that _self gave the Robin file the same browser space as the Batman file. Basically it works like a standard link. Next is _parent. The code used is :
Notice that _parent gave the Robin file the same ability as the _top command. Lastly is _TOP. The code used is :
Notice that _TOP gave the Robin file the a new browser window, just remember not to go overboard with these commands.
|
| Thats Frames...well not quite Well you have just seen all of the code needed to make a frames capable web site. But what happens when someone gets to your site and doesn't have a frames capable browser. Are they out of luck?? No, whenever making a frames capable site you should always use the tags <noframes>, <body>....</body>, </noframes>. What this means is that you make a web page without frames and stick it inbetween that set of tags. This way non frames capable browsers will have something to lok at when they hit your site. You do this in your main frame page so the code for that would look like this :
<html> Thats it for frames. And yes using frames means you should duplicate your work for non frame using systems. Hard work, yes, apreciated always.
|
|
| Click on Advanced Lesson 10 to continue, or click here (Top) to return to the top of document |