Tutorial 14: You've been Framed, Part I - HTML with Style | 6 | WebReference

Tutorial 14: You've been Framed, Part I - HTML with Style | 6

index1234567exercises1

Tutorial 14: You've been Framed, Part I

Loading new documents into an existing frameset

After a document is loaded into a frame, any subsequent documents loaded by following links in that document are displayed in the same frame. This can be nice since you can have a fixed "decor" around your main page that supplies standard services. However, in order for this to be truly useful, you need to be able to display the tail of a hyperlink from one frame in another frame. This makes it possible, for instance, to have a fixed table of contents in one frame, with links to sections of a multi-page text, and displaying the relevant section every time such a link is clicked on by the user.

This is accomplished by the TARGET attribute. The TARGET attribute applies to the A, LINK, AREA, FORM, and BASE elements.

Target frame attribute

TARGET (Frame target)
Specifies the name of the frame in which the link's tail will be displayed. Alternatively, can be used to specify the name of a browser window in which to display the document, or may be one of the special frame targets (see text)

When TARGET is set for an A, LINK, or AREA element that specifies a hyperlink, the destination of this link is loaded in the frame named in the value of the attribute. You can also set this attribute on a FORM element so that the ACTION URL is loaded in a different frame. For example, in the framed HTML with Style front page we saw above, the links in the sidebar that lead to the Tools, Tutorials, Style Watch and About pages are loaded in the central frame. Recall our frameset document:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN"
"https://www.w3.org/TR/REC-html40/frameset.dtd">
<HTML>
 <HEAD>
  <TITLE>HTML with Style</TITLE>
 </HEAD>
 <FRAMESET ROWS="170,*,17%">
  <FRAME NAME="ad" SRC="example2.html" NORESIZE SCROLLING="no">
  <FRAMESET COLS="250,*">
   <FRAME NAME="sidebar" SRC="example3.html">
   <FRAME NAME="main" SRC="example4.html">
  </FRAMESET>
  <FRAME NAME="footer" SRC="example5.html" NORESIZE SCROLLING="no">
 </FRAMESET>
</HTML>

The frame called sidebar initially holds the document example2.html. By default, a link in this document would be of the following form:

<A HREF="watch/">Style Watch</A>

If the user followed this link, the document found by dereferencing the URL watch/ would be loaded in the sidebar frame. However, we can use the following syntax instead:

<A HREF="watch/" TARGET="main">Style Watch</A>

This would load the Style Watch page in the frame called main instead. You can try this by going back to the frameset and clicking on one of the links in the sidebar.

You can also set the default frame target for a document by setting the TARGET attribute on the BASE element. The value of this attribute will be the default target for all links in the document instead of the current frame. You can override this value by setting the TARGET attribute for individual links.

index1234567exercises1

URL: https://www.webreference.com/html/tutorial14/5.html

Produced by Stephanos Piperoglou
Created: June 30, 1999
Revised: June 30, 1999