When a link is clicked within an HTML frame to load another document, then by default the document will load into the same frame as the link.
To load a document into a frame, other than the frame containing the link, requires the target attribute to be used within the <a> element in conjunction with the name attribute within the <frame> element.
The name attribute works in the same way with frames as it does with windows since frames are actually treated as windows within HTML.
If we take a 2 column frameset where the left frame contains a link to load a document into the right frame then the frameset will look like that below.
If we wish a document called "page_2.htm" to load into the right hand frame from a link within the left hand frame then the link within "left_column.htm" will take the form below.
The target attribute can also be used with the <form> element to send the contents of the form to a script then output the results to another frame as shown below.
A Form Targeting Another Frame
<form action="myform.php" method="post" target="right_column">
<!-- Form Elements -->
<input type="submit" name="Send">
</form>
If it's required that all returned pages be loaded into a particular frame then the <base> can be used within the <head> element thus.
Using the Base Element for Targeting
<head>
<base target="right_column">
</head>
Target Values
The <target> attribute can take on a number of special values.
target="_self" which loads the document into the current frame. This is the default if no target attribute is used.
target="_blank" which loads a document into an instance of a new browser window. This will also happen if the target attribute is the name of a frame or window that doesn't already exist.
target="_parent" loads a document into the parent of this frame. If the frameset is not nested then the parent will be the browser window. If the frameset is nested then the parent will either be...
The browser window, if the frameset was placed directly within an outer frameset.
A frame within the outer frameset if the frame loaded in a document with the inner frameset defined within it.
target="_top" which loads a document into the browser window overwriting any frames present.
Care must be taken when linking to external websites since in most cases it's undesirable to have a page from an external website displayed inside one of your frames.
To avoid this, within all links to external websites, use the target="_blank" attribute, to load the document into a new window, or the target="_top" attribute, to load the document into the existing browser window.