Hyper Text Markup Language (HTML) Question:
Download Questions PDF

How do I make sure my framed documents are displayed inside their frameset?

Answer:

When the sub-documents of a frameset state are accessed directly, they appear without the context of the surrounding frameset.
If the reader's browser has JavaScript support enabled, the following script will restore the frameset:

<SCRIPT TYPE="text/javascript">
if (parent.location.href == self.location.href) {
if (window.location.href.replace)
window.location.replace('frameset.html');
else
// causes problems with back button, but works
window.location.href = 'frameset.html';
}
</SCRIPT>
A more universal approach is a "restore frames" link:

<A HREF="frameset.html" TARGET="_top">Restore Frames
Note that in either case, you must have a separate frameset document for every content document. If you link to the default frameset document, then your reader will get the default content document, rather than the content document he/she was trying to access. These frameset documents should be generated automatically, to avoid the tedium and inaccuracy of creating them by hand.
Note that you can work around the problem with bookmarking frameset states by linking to these separate frameset documents using TARGET="_top", rather than linking to the individual content documents.

Download HTML Interview Questions And Answers PDF

Previous QuestionNext Question
How do you create tabs or indents in Web pages?Can I have two or more Submit buttons in the same form?