Interview Questions

How do I make a link or form in one frame update another frame?

HTML Interview Questions and Answers


(Continued from previous question...)

75. How do I make a link or form in one frame update another frame?

In the frameset document (the HTML document containing the <frameset> <frame> tags), make sure to name the individual frames using the NAME attribute. The following example creates a top frame named "navigation" and a bottom frame named "content":

<frameset rows="*,3*">
    <frame name="navigation" src="navigation.html">
    <frame name="content" src="content.html">
    <noframes><body>
        <!-- Alternative non-framed version -->
    </body></noframes>
</frameset>

Then, in the document with the link, use the TARGET attribute to specify which frame should be used to display the link. (The value of the TARGET attribute should match the value of the target frame's NAME attribute.) For example:

<a target="content" href=...>
To target a form submission, use the TARGET attribute of the FORM element, like this:

<form target="content" action=...>
Note that when forms are processed entirely by JavaScript, the target frame must be specified in the JavaScript. The value of the TARGET attribute is irrelevant.
Normally, the default target frame is the current frame ("_self"). To change the default target for every link/form on the page, use the TARGET attribute of the BASE element, like this:

<base target="content">

(Continued on next question...)

Other Interview Questions