Tuesday 11 April 2017

Frames name and target attributes

The most popular uses of frames is to place navigation bars (links) in one frame and then load main pages into a separate central frame. this is done using the name attribute of the <frame> tag and the target attribute of the <a> tag.
For example :
where a target.html has following code:

<html>
<head>
<title>HTML target frame</title>
</head>
<frameset cols="150,*">
<frame src="menu.html" name="menu_page">
<frame src="main.html" name="main_page">
</frameset>
</html>

In this example we have create two frames. the first frame is 150 pixels wide and will contain the menubar implemented by menu.html file. the second column fills in remaining space. It will contain the main part of the page and it is implemented by main.html file. for both the links available in the menubar, we have mentioned the target frame as main_page. so whenever you click any of the links in menubar the link will open in main_page.

menu.html
<html>
<head>
<title>MENU html file
</title></head>
<body bgcolor="green">
<H3>Menu
</H3>
<br>
<a href="http://www.careersoft-tech.blogspot.com" target="main_page">careersoft</a>
<br>
<a href="http://www.dotprogramming.blogsport.com" target="main_page">dotprogramming</a>
<br>
</body>
</html>

The HTML code of the main.html file:

<html>
<head>
<title>main html file</title>
</head>
<body bgcolor="pink">
<H3>This is the main page of the Website</H3>
</h3>Content for the link will be displayed here:</h3>
</p>Click on a link in the menu
</p>
</body>
</html>
The Browser View :


Click on any link in the Menu to see the webpage in the main frame.



2 comments: