Hyper Text Markup Language (HTML) Question:
Download Job Interview Questions and Answers PDF
How do I update two frames at once?
Answer:
There are two basic techniques for updating multiple frames with a single link: The HTML-based technique links to a new frameset document that specifies the new combination of frames. The JavaScript-based solution uses the onClick attribute of the link to update the additional frame (or frames).
The HTML-based technique can link to a new frameset document with the TARGET="_top" attribute (replacing the entire frameset). However, there is an alternative if the frames to be updated are part of a nested frameset. In the initial frameset document, use a secondary frameset document to define the nested frameset. For example:
<frameset cols="*,3*">
<frame src="contents.html" name="Contents">
<frame src="frameset2.html" name="Display">
<noframes>
<!-- Alternative non-framed version -->
</body></noframes>
</frameset>
A link can now use the TARGET="Display" attribute to replace simultaneously all the frames defined by the frameset2.html document.
The JavaScript-based solution uses the onClick attribute of the link to perform the secondary update. For example:
<a href="URL1" target="Frame1" onClick="top.Frame2.location='URL2';">Update frames
The link will update Frame1 with URL1 normally. If the reader's browser supports JavaScript (and has it enabled), then Frame2 will also be updated (with URL2).
The HTML-based technique can link to a new frameset document with the TARGET="_top" attribute (replacing the entire frameset). However, there is an alternative if the frames to be updated are part of a nested frameset. In the initial frameset document, use a secondary frameset document to define the nested frameset. For example:
<frameset cols="*,3*">
<frame src="contents.html" name="Contents">
<frame src="frameset2.html" name="Display">
<noframes>
<!-- Alternative non-framed version -->
</body></noframes>
</frameset>
A link can now use the TARGET="Display" attribute to replace simultaneously all the frames defined by the frameset2.html document.
The JavaScript-based solution uses the onClick attribute of the link to perform the secondary update. For example:
<a href="URL1" target="Frame1" onClick="top.Frame2.location='URL2';">Update frames
The link will update Frame1 with URL1 normally. If the reader's browser supports JavaScript (and has it enabled), then Frame2 will also be updated (with URL2).
Download HTML Interview Questions And Answers
PDF
Previous Question | Next Question |
My page looks good on one browser, but not on another. | How do I make a link or form in one frame update another frame? |