Links within frames

In a normal HTML document, when you click on a link, the current document is replaced with a new one in the browser window. When using frames, the document loading scheme differs from the standard one. The main difference is the ability to upload a document to the selected frame from another. For this purpose, use the target parameter of the <A> tag (example 1). The value is the name of the frame into which the document specified by the name parameter (example 2) will be loaded.

Example 1. Reference to another frame

Valid HTML
<! DOCTYPE HTML PUBLIC "- // W3C // DTD HTML 4.01 Transitional // EN" "http://www.w3.org/TR/html4/loose.dtd">
<Html>
<Head>
<Meta http-equiv = "Content-Type" content = "text / html; charset = windows-1251">
<Title> Frame reference </ title>
</ Head>
<Body>
<P> <a href="text.html" target="CONTENT"> Content </a> </ p>
</ Body>
</ Html>

Example 2. Frame name

Valid HTML
<! DOCTYPE HTML PUBLIC "- // W3C // DTD HTML 4.01 Frameset // EN" "http://www.w3.org/TR/html4/frameset.dtd">
<Html>
<Head>
<Meta http-equiv = "Content-Type" content = "text / html; charset = windows-1251">
<Title> File index.html </ title>
</ Head>
"<Frameset cols =" 200, * ">
<Frame src = "menu.html" name = "MENU" noresize>
<Frame src = "content.html" name = "CONTENT" >
</ Frameset>
</ Html>

In example 2, the frame is named CONTENT. To load the document into the specified frame, use the parameter target = "CONTENT" .

The frame name must begin with a number or a Latin letter. The reserved names are:

_blank - loads the document into a new window;
_self - loads the document into the current frame;
_parent - loads the document into the frame occupied by the parent, if the parent frame does not exist, the parameter also acts as _top ;
_top - cancels all frames and loads the document into a full browser window.

To simultaneously update two frames at the same time and load different documents into them, you will have to use JavaScsript (example 3).

Example 3. Simultaneous loading of documents into two frames

Valid HTML
<! DOCTYPE HTML PUBLIC "- // W3C // DTD HTML 4.01 Transitional // EN" "http://www.w3.org/TR/html4/loose.dtd">
<Html>
<Head>
<Meta http-equiv = "Content-Type" content = "text / html; charset = windows-1251">
<Title> Frame reference </ title>
</ Head>
<Body>
<P> <a href="menu2.html" onClick= "parent.frames.CONTENT.document.location='content2.html'"> Click me, click </a> </ p>
</ Body>
</ Html>

In this example, Usage is used as usual, but as an option, an onClick event is added that tracks the click on the link. Note that the name of the frame should also be written as specified in the parameter name (in this case, by uppercase characters). JavaScript is case sensitive and has a perverse attitude to any incorrect spelling.

Copyright © www.htmlbook.ru