HTML frame
HTML frames are used to divide your browser window into multiple sections where each
section can load a separate HTML document. A collection of frames in the browser window is known as a frameset. The window is divided into frames in a similar way the tables are
organized: into rows and columns.
Disadvantages of Frames
There are few drawbacks with using frames, so it's never recommended to use frames in your webpages:
1.Some smaller devices cannot cope with frames often because their screen is not big enough to be divided up.
2.Sometimes your page will be displayed differently on different computers due to different screen resolution.
3.The browser's back button might not work as the user hopes.
4.There are still few browsers that do not support frame technology.
Creating Frames
To use frames on a page we use <frameset> tag instead of <body> tag. The <frameset>
tag defines, how to divide the window into frames. The rows attribute of <frameset> tag
defines horizontal frames and cols attribute defines vertical frames. Each frame is
indicated by <frame> tag and it defines which HTML document shall open into the frame.
If a user is using any old browser or any browser, which does not support frames then<noframes> element should be displayed to the user.
So you must place a <body> element inside the <noframes> element because the<frameset> element is supposed to replace the <body> element, but if a browser does not understand <frameset> element then it should understand what is inside the <body>element which is contained in a <noframes> element.
Example
<!DOCTYPE html><html><head><title>HTML Target Frames</title></head><frameset cols="200, *"> <frame src="/html/menu.htm" name="menu_page" /> <frame src="/html/main.htm" name="main_page" /> <noframes> <body> Your browser does not support frames. </body> </noframes></frameset></html>
Here, we have created two columns to fill with two frames. 1. The first frame is 200 pixels wide and will contain the navigation menu bar implemented by menu.htm file. 2. The second column fills in remaining space and will contain the main part of the page .
Following is the content of menu.htm file
<!DOCTYPE html><html><body bgcolor="#4a7d49"><a href="http://www.google.com" target="main_page">Google</a><br /><br /><a href="http://www.microsoft.com" target="main_page">Microsoft</a><br /><br /><a href="http://news.bbc.co.uk" target="main_page">BBC News</a></body></html>
Following is the content of main.htm file:
<!DOCTYPE html><html><body bgcolor="#b5dcb3"><h3>This is main page and content from any link will be displayed here.</h3><p>So now click any link and see the result.</p></body></html>
When we load test.htm file, it produces followed results:
The <frameset> Tag AttributesFollowing are important attributes of the <frameset> tag:
Attribute Descriptioncols Specifies how many columns are contained in the frameset and the size of each column. rows This attribute works just like the cols attribute and takes the same values, but it is used to specify the rows in the frameset.
border This attribute specifies the width of the border of each frame in pixels.
frameborder This attribute specifies a three-dimensional border should bedisplayed between frames.
You can define an inline frame with HTML tag <iframe>. The <iframe> tag is notsomehow related to <frameset> tag, instead, it can appear anywhere in your document.
The <iframe> tag defines a rectangular region within the document in which the browsercan display a separate document, including scrollbars and borders.
The src attribute is used to specify the URL of the document that occupies the inline frame.
Example
Following is the example to show how to use the <iframe>:<!DOCTYPE html><html><head><title>HTML Iframes</title></head><body><p>Document content goes here...</p><iframe src="/html/menu.htm" width="555" height="200"> Sorry your browser does not support inline frames.</iframe><p>Document content also go here...</p></body></html>
This will produce the following result:
Document content goes here...Document content can also go here...
The <Iframe> Tag Attributes
Most of the attributes of the <iframe> tag, including name, class, frameborder, id,longdesc, marginheight, marginwidth, name, scrolling, style, and title behave exactly like 

EmoticonEmoticon
Note: Only a member of this blog may post a comment.