Webmaster
-
Frames



You were given the script for frames in the chapter Your first website. If you are happy to use that example for your website there is no need to learn about them. But if you want to change the format then delve here.

Firstly, remember that columns run down the screen, and rows run across the screen.
Here is what I did:
I split my screen into columns, called framesets.
Open index_major.htm in Notepad.
Note there are no body tags, no <body></body>.
Instead we have frames as scripted here:

<frameset cols="160,621,*" frameborder="0" border="0" >

"border" for Netscape; "frameborder" for Internet Explorer; framespacing="n" increases space between frames but used by only Internet Explorer, so do not use.

f1 includes 2 frames: logo, index.
<frameset rows="85,*" frameborder="no" border="0" >
<frame name="logo" src="1_logo.htm" scrolling="no" marginheight="0" marginwidth="0" />
<frame name="index" src="2_index.htm" scrolling="auto" marginheight="0" marginwidth="0" />
</frameset>

f2 includes 1 frame for content: f2
<frameset frameborder="no" border="0" >
<frame name="f2" src="3_first_page.htm" scrolling="auto" marginheight="0" marginwidth="0" />
</frameset>
f3 includes 1 frame for advertising or photos: f3
<frameset frameborder="no" border="0" >
<frame name="f3" src="4_f3.htm" scrolling="auto" marginheight="0" marginwidth="0" />
</frameset>
</frameset>

This looks very complicated, but when we begin we create a simple framework then keep expanding, like this:


<frameset cols="160,621,*" frameborder="0" border="0" >

</frameset>
</html>

We have now created a set of 3 frames with the widths of 160px, 621px and the 3rd has whatever pixels are left over, because we do not know how wide the user will set his window.
Note that we said there is no frameborder and no border. Actually a frameborder is the same as a border, but one browser uses one term and another browser uses the other, so we cover both.
Now we include 3 frames within this frameset.

<frameset cols="160,621,*" frameborder="0" border="0" >
<frame name="f1" src="1_index.htm" scrolling="auto" marginheight="0" marginwidth="0" />
<frame name="f2" src="3_first_page.htm" scrolling="auto" marginheight="0" marginwidth="0" />
<frame name="f3" src="4_f3.htm" scrolling="auto" marginheight="0" marginwidth="0" />
</frameset>
</html>

This is what we have done:
You should add the script which precedes this, and test it.
We could let it go at that, but I prefer a small logo in the top-left corner, so the user always know at which site he is. When that disappears, he knows instantly he has left my site (and needs to click the [Back] button to return.

To do this I swap the left-most frame for another frameset into which I put 2 frames.

Just like before, we begin:

<frameset rows="85,*" frameborder="no" border="0" >
</frameset>
We do not know how long is the user's window or screen so we put "85,*" to fix the size of the logo but leave the other frame to take up the rest of the space.

Then we expand by adding the 2 frames inside the frameset:
<frame name="logo" src="1_logo.htm" scrolling="no" marginheight="0" marginwidth="0" />
<frame name="index" src="2_index.htm" scrolling="auto" marginheight="0" marginwidth="0" />
Again we call a page for each frame.
And that is all there is to it.

Knowing these techniques you can alter the number of frames. You might prefer your logo to be at the top of the middle frame, and you can now do that.

You might wish to fix the width of the 3rd frame at 150px because your advertisements are just under this size. This would enable you to vary the middle frame. You now know how to do that.

If you fix the widths of all frames, then if the monitor is too small, the user will need a horizontal scrollbar, and he will not like it.
But it is your website and you can do what you like.

You can use frames within your main window. These are called "iFrames" or Inline Frames, which insert an XHTML or HTML document within another document.
This is part of the HTML 4 specification. One advantage of iFrames is that they can have their own scrollbars. However, at this early stage of your webmastering, stick to the KISS principle – keep it simple. Furthermore, for users who want to copy your content, iFrames are a nuisance.

You might have wondered why my website splits into 4 vertical framesets, giving index-content-content-border, and here are some of the reasons:
My website is designed for monitors 800px wide.
With this 4-frame layout, is there any need for iFrames ?