FramesThe frames function is to divide in parts the browser window in order to present more documents at the same time. Basic structureThis is basic structure of a page with two frames.If the browser does not support frames, it will show an alternative content (noframe content). To build a page using frames, follow these steps:
<HTML> <HEAD> <TITLE>Frame example</TITLE> </HEAD> <FRAMESET cols="20%, 80%"> <FRAME src="pageone.htm"> <FRAME src="pagetwo.htm"> <NOFRAMES> <BODY> <P> (Your browser does not support frames.) <H1>Contents</H1> <A href="pageone.htm">Page one</A> <BR> <A href="pagetwo.htm">Page two</A> <BR> </P> </BODY> </NOFRAMES> </FRAMESET> </HTML> The target files specified in the example above: <HTML> <HEAD> <TITLE>Page one</TITLE> </HEAD> <BODY> <P> This is "pageone.htm". It's an example of the use of frames. You can see more documents into the same window. </P> </BODY> </HTML> <HTML> <HEAD> <TITLE>Page two</TITLE> </HEAD> <BODY> <P> This is "pagetwo.htm". This page shows the use of frames. The browser presents more documents at the same time. </P> </BODY> </HTML>Try this:
Frame attributesFrame borderThe border of the frame becomes invisible using the frameborder="0" attibute:<FRAME src="example.htm" frameborder="0">
No resizeable frameThe frame window becomes no resizeable using the noresize attribute:<FRAME src="example.htm" noresize>
Scrolling barWe can enable or disable the scrolling bar of the frame window using the proper scrolling attribute:
<FRAME src="example.htm" scrolling="no">
Frame marginsWe can specify the width in pixels of left and right margin of a frame, using the marginwidth attribute:<FRAME src="example.htm" marginwidth="10">
We can specify the width in pixels of top and bottom margin of a frame, using the marginheight attribute:
<FRAME src="example.htm" marginheight="20">
All these attributes can be used at the same time. For example:
<FRAME src="example.htm" noresize scrolling="no" marginwidth="10" marginheight="10">
Nested FramesetsWe can place a frameset into another frameset.For example: if we need to place three frames using the following layout....
<HTML> <HEAD> <TITLE>Nested frameset example</TITLE> </HEAD> <FRAMESET cols="40%, 60%"> <FRAME src="pageone.htm"> <FRAMESET rows="50%, 50%"> <FRAME src="pagetwo.htm"> <FRAME src="pagethree.htm"> </FRAMESET> <NOFRAMES> <BODY> <P>Your browser does not support frames.</P> </BODY> </NOFRAMES> </FRAMESET> </HTML> Target frameWe can assign to a link the property to open the relative document into a target frame identified with a name.Example: The following document has two frames; into the left frame there is a document called list.htm, containing a list of links. Selecting a link from the list, the relative document will always open into the right frame, called chapter. <HTML> <HEAD> <TITLE>Target Frame example</TITLE> </HEAD> <FRAMESET cols="20%, 80%"> <FRAME src="list.htm"> <FRAME name="chapter" src="1.htm"> <NOFRAMES> <BODY> <P>Your browser does not support frames.</P> </BODY> </NOFRAMES> </FRAMESET> </HTML>This is the code of list.htm: <HTML> <HEAD> <TITLE>List</TITLE> </HEAD> <BODY> <H1>Index</H1> <UL> <LI><A href="1.htm" target="chapter">Page 1</A></LI> <LI><A href="2.htm" target="chapter">Page 2</A></LI> <LI><A href="3.htm" target="chapter">Page 3</A></LI> <UL> </BODY> </HTML> Next page : how to add doctype definition and meta informations. |