To control the behavior of hyperlinks in a framed page, there are two required steps:
To assign a name to a frame, add the name attribute to the frame tag. The syntax for this attribute is:
where frame_name is any single word you assign to the frame tag. The name is CASE SENSITIVE.
The target attribute of the anchor tag <a> specifies a frame where the document will be loaded. The syntax for this is:
where frame_name is the name you have assigned to a frame.
The <base> tag is used within the <head> tags of your HTML file and is intended to specify global options for the page. The syntax of this attribute is:
Click the button to open a pop-up window with two frames:
This layout is produced by the following HTML files:
Frameset definition | Left frame |
---|---|
<html> <frameset cols="*,*"> <frame src="lframe2.html" name="left" /> <frame src="rframe2.html" name="right" /> </frameset> </html> |
<html><head> <base target="right" /> </head> <body bgcolor="orange"> <a href="rframe2.html"> Open document 1</a><p> <a href="rframe3.html"> Open document 2</a><p> <a href="rframe2.html" target="left"> Load document 1 here</a> </body> </html> |
Reserved target names are special names that can be used in place of a frame name as the target. They are described in the following table:
Target name | Comments |
---|---|
_blank | loads the document into a new browser window |
_self | loads the document into the same frame or window that contains the hypertext link tag |
_parent | loads the document into the frame that contains the frame with the hyperlink tag |
_top | loads the document into the full display area replacing the frame layout |
Note that the reserved target names are CASE-SENSITIVE.
Example: consider the following frame definitions:
Top frameset | File rframe4.html |
---|---|
<html> <frameset rows="30%,*"> <frame src="rframe2.html" /> <frame src="rframe4.html" /> </frameset> </html> |
<html> <frameset cols="*,*"> <frame src="rframe2.html" /> <frame src="rframe2.html" /> </frameset> </html> |
By clicking one of the buttons below opens a pop-up window. The document in the right bottom frame of this window will be replaced with a new one, which contains a link with the corresponding setting of the target attribute. Clicking on this link in the frame causes downloading another document into the corresponding frame.