Despite the fact that sites with frames are becoming increasingly rare, learning HTML would be incomplete without considering the topic of frames. In addition, frames, in a sense, have occupied their niche and are used for administration and help systems. Where the disadvantages of frames are not particularly important, but the advantages, on the contrary, are actively in demand.

The tag is used to create a frame , which replaces the tag in a document and is used to divide the screen into areas. Inside this tag there are tags , which point to the HTML document intended to be loaded into the area (Figure 13.1).

Rice. 13.1. Example of splitting a browser window into two frames

When using frames, you need at least three HTML files: the first defines the frame structure and divides the browser window into two parts, and the remaining two documents load into the specified windows. The number of frames is not necessarily equal to two, maybe more, but not less than two, otherwise the meaning of using frames is completely lost.

Let's consider the stages of creating frames based on the page shown in Fig. 13.1. We will need three files: index.html - defines the structure of the document, menu.html - loaded into the left frame, and content.html - loaded into the right frame. Of these, only index.html differs in the structure of its code from other files (example 13.1).

Example 13.1. index.html file

Frames

If frames are used, the following document type is written in the first line of code.

Thetells the browser that it is dealing with frames, this line of code is required. Container contains typical information such as page encoding and document title. Just keep in mind that the header remains the same as long as HTML files are opened inside frames.

IN in this example The browser window is split into two columns using the cols attribute, the left column occupies 100 pixels, and the right column takes up the remaining space specified by the asterisk symbol. The width or height of frames can also be set as a percentage, similar to tables.

In the tag The name of the HTML file loaded into the specified area is specified using the src attribute. A file called menu.html will be loaded into the left window (Example 13.2), and content.html will be loaded into the right window (Example 13.3). It is advisable to give each frame a unique name so that documents can be loaded into the specified window using the name attribute.

Example 13.2. File menu.html

Site navigation

In this example, the gray background on the page is set using styles, which will be discussed later.

Example 13.3. File content.html

Site content

CONTENT



Let's consider a more complex example with three frames (Fig. 13.2).

Rice. 13.2. Dividing a page into three frames

In this case, the tag is used again , but twice, with one tag nested within the other. Horizontal partitioning is created through the rows attribute, where percentage notation is used for variety (Example 13.4).

Example 13.4. Three frames

Frames

As can be seen from this example, the container with the rows attribute first creates two horizontal frames, but replaces the second frame with another one , which repeats the structure you already know from Example 13.1. To prevent a vertical scroll bar from appearing and the user not being able to independently change the size of the top frame, the scrolling="no" and noresize attributes have been added.

Surely you have heard more than once about such a concept as frames. You can read about them in any html textbook, as well as on resources on website creation. After studying many examples and descriptions, I decided to tell everything about frames in my own words in a very simple form. The pros, cons and future of frames will be discussed at the very bottom of this page. So, what are frames in html?

What are Frames in html

Frame(English frame) - some connectable independent area on a web page.

Don't be alarmed that this sounds a little confusing. Let's immediately give the simplest example and then everything will become clear.

Open help in any program (it could be notepad, some program, browser, etc.). Almost always you will see a help consisting of two parts (navigation on the left, content on the right). The left and right parts are just separate frames. Below is a screenshot taken from the help of the most ordinary Windows notepad:

Fig 1. Using frames using the notepad help as an example

What you see is a web page consisting of two separate independent frames. Let's give an example html code such a frame from help.

Example with frames No. 1 (doing help)

In the framework above, the help discussed above will look like this:


Fig 2. Framework for using frames for example No. 1

Splitting a page into areas using frames is very similar to HTML table layout (see HTML table tag). An example code for such a page might look like this:

<span>Example No. 1 of an html page with frames</span>
Explanation for example No. 1

As you can see from the code above, a page created from frames is very similar to an ordinary html page: there is an opening html tag, a section , title , but there is one big difference. You probably noticed that the body tag, which is responsible for the body of the page, is missing. The tag is inserted instead <frameset>, which is responsible for the body of the page. This tag has two attributes cols="25%,75%" , which means splitting the entire body of the page into two areas vertically in a 1:3 ratio. The first area will take up 25% of the width of the entire screen (it will contain the first menu.html frame), the second area will take up 75% of the width of the entire screen (it will contain the second content.html frame).</p> <p>The last completely optional tag is <noframes>. It is needed for browsers that do not support frames. If the browser does not support frames, it is recommended to politely inform the user about this through this tag.</p> <p>By the way, please note that for the tag <frame>no closing tag needed.</p> <p>I hope that now you have an idea about frames. To understand more difficult examples, let's try to create a simple html page consisting of 4 frames. This will be example #2.</p> <h2>Example with 4 frames #2</h2> <p>Framework for example 2:</p> <p><img src='https://i0.wp.com/zarabotat-na-sajte.ru/uroki-html/img/primer2-frame-karkas.jpg' width="100%" loading=lazy loading=lazy><br>Fig 3. Framework for using frames for example No. 2</p> <p>The code of the original HTML page with the frame will be as follows:</p> <blockquote><html > <head > <title ><span>Example No. 2 of an html page with frames</span> <span>Your browser does not support displaying frames</span>

Top.html file code

<span>File top.html - site header</span>

Example No. 2

And here there could be a logo and more :)

Menu.html file code

<span>File menu.html - site menu</span>

Content.html file code

<span>File content.html - site content</span>

Home page

Site content. The content.html file is now open
This is the initial state of our frame. Let's call this file "Master Page"

File code about-site.html

<span>File about-site.html - Page about the site</span>

About the site

Page about the site. The file about-site.html is now open

File code about-autor.html

<span>File about-autor.html - about the author</span>

about the author

About the author page. The file about-autor.html is now open

Footer.html file code

<span>File footer.html - about the site</span> Website footer. The file footer.html is now open
Explanation for example No. 2

Initially, the entire page is divided into three areas horizontally in a ratio of 3:14:3. The rows="15%,70%,15%" attribute is responsible for this. The first frame in our example is the header (we called it top.html), 15% of the height space is allocated to it. Next comes a large frame occupying 70% of the height. We split it into two parts using cols="25%,75%" in a ratio of 1:3. On the left there will be a frame menu.html , on the right content.html . We specifically named the second frame name="main" in order to be able to switch pages. Note that in the menu.html file, each link has a target="main" attribute attached to it, which allows the items to be loaded into an area called main when the link is clicked. At the bottom of the site is the last frame footer.html.

If you implement example No. 2, you should get the following HTML page in its original state:


Fig 4. Example No. 2 - initial state

When you go to the about page of the site, the page will look like this:


Fig 5. Example No. 2 - second state


Fig 6. Example No. 2 - third state

Tag

The optional attributes of this tag are width="width" and height="height" , and the required attribute is src="frame address" .

Tag Attributes and Properties

1. COLS attribute="Parameters"
Sets the number of vertical page splits.

2. ROWS="Parameters" attribute
Sets the number of horizontal page splits.

Now let's look at how you can set the partitioning parameters.

a) Using the number, which will correspond to the number of pixels. For example, cols = "100,100,300" sets the page to be divided into three areas, each of which will be 100 pixels, 100 pixels and 300 pixels wide, respectively.

b) Using percentages of the total width/height. In the examples discussed above, we used percentage division, so it seems pointless to give an example.

c) Using * (asterisk). For example, cols = "2*,3*,100" sets the first two areas to a 2:3 ratio, and the third area to be 100 pixels wide.

All three methods can be combined. For example, cols="2*,100,15%,4*" .

3. Frameborder="(yes|no)" attribute
Determines whether a frame has a border. If the answer is yes, then the next fourth border attribute is in effect.

4. Attribute border="parameter"
In pixels, border specifies the border thickness of the frame area. For example, frameborder = "2" specifies an area with a selected outline of 2 pixels.

5. bordercolor="color" attribute
Specifies the color of the border, if there is one. The color can be specified either in words or in code (see html color palette).

Note: Please note that the tag need a closing tag .

Tag Attributes and Properties

1. Attribute src="element address"
The full URL to the element address must be specified as a parameter here. This attribute is required. He is already familiar to you, because... it was present in examples 1 and 2.

2. Attribute marginwidth="number"
Sets the width of the indentation inside the frame from the borders in pixels. For example, marginwidth="10" will set the content margin to the left and right of the frame border.

3. Attribute marginhight="number"
Similar to the second one with the only difference that it sets the height offset.

4. Scrolling="(yes|no|auto)" attribute
Sets the ability to scroll the frame if it could not fit within the area allocated to it. The default value is auto (means create a scroll if necessary).

5. Noresize attribute
If this attribute is set, the user is prohibited from independently changing the frame boundaries. By default, this attribute is not set and the user can change the boundaries as he wants.

5. Attribute name="title"
This attribute can be used to give the frame a name. This is necessary so that other frames can access this frame. Example No. 2 deals with just such a case.

Note:
The name must not begin with an underscore "_".

6. Attributes frameborder, border and bordercolor
These three attributes are the same as frameset (see frameset attributes above).

Advantages and disadvantages of frames

Pros of frames

  • The ability to display several pages independently in one window (example 1 and 2 above);
  • Ability to switch page content without reloading the page (only one area of ​​the screen changes);
  • The ability to flexibly build a site structure (header, menu, footer, etc. - all static information is stored separately in files, and this allows you to quickly edit part of the site);
  • The user can change the size of the viewport himself if the noresize option is not set;

Cons of frames

  • Search engines index framed sites poorly because they are unable to interpret the loaded files in frames. The search engine distinguishes pages by their address (URL), and for frames, despite different states, the page address does not change. This is contrary to the rules of the search engine, which means it is not a fact that the search engine will be able to index the site.
  • It is impossible to bookmark a site in frames, because The page URL will be the same. Thus, you can only save the initial state frame.
  • Not all browsers support frames.

The future of frames:
Many webmasters have long ago begun to abandon frames. This is due to the difficulties of promotion in search engines. Now everyone is switching to Ajax as a more dynamic and modern way of displaying information on one page of the site.

Dear reader, we have reviewed the tags html document concerning frames. Despite the dubious future of this area, every webmaster should know about frames.

What are frames?

To make a site more functional, to place a large amount of information and links in the most convenient form for the visitor, it is not at all necessary to use Flash technologies. All this is possible using the HTML language, in which you can create frames.

In layman's terms, frames are additional scroll bars in one window. Getting to the site, the visitor sees on the same page two windows at once - one, as a rule, with menu items or another important information, and the other with content (text, prices, etc.). In this case, the visitor can more conveniently view fairly voluminous pages and have the most important information in front of his eyes at the same time.

If we delve into the details, a page with frames consists of at least three HTML pages at once - two visible to the user and one service (coordinating the display of frames). Visible pages are frames that can be accessed individually or simultaneously.

Undoubtedly, an important advantage of using frames is high quality usability. The page interface becomes many times more convenient than when using standard methods markings.

At one time, 5-6 years ago, frames gained popularity among many webmasters. Today they are used only on those sites where it is simply impossible to do without them, since, unfortunately, frames have significant disadvantages in terms of promotion.

Frames - good or bad?

You can consider the usefulness of frames from three positions - from the position of the user, from the position of the SEO specialist and the webmaster.

In the first case, the attitude towards frames is ambiguous. On the one hand, sometimes you simply cannot do without them, and they successfully replace service pages that open in other windows. And frames only improve the usability of large pages, because the user can use the menu in another window at any time.

On the other hand, they don't really improve the design of the page. It is quite difficult to achieve a good appearance if frames are used. And, of course, not all browsers support frames, which can alienate an entire army of potential buyers, clients, or just visitors.

From a webmaster's perspective, using frames makes it easier to compose pages and polish the interface. After all, it is much easier to create one page with the entire menu and other important information than to place this content on every page of the site. However, this is where the simplifications end and complications begin that a non-specialist does not need to know about. Moreover, now almost no one works with pure html - CMS allows you to do everything automatically.

The position of an SEO specialist is much tougher. Frames simply do not allow search robots to pass beyond the main page. Of course, there are some tricks that allow you to index the internal pages of a site, but these are still “tricks” that are not approved by any search engine.

The influence of frames on website promotion.

No matter how experienced a website promotion specialist may be, he will not be able to give any guarantees in promotion if frames are used on the resource. Unfortunately, this technology is included in the “black list” of elements that complicate search engine promotion, along with flash and stolen content. But the latter may not yet be noticed, but the same cannot be said about frames.

So, how and what does the use of frames affect promotion?

The impact is serious. The fact is that it is on the frames that all the important links to the internal pages of the site are located. And in order to register them, the layout designer does not need to use tags . Namely, it is by this tag that the search robot determines that in front of it is a link through which you can go to another page and index it (or add a couple more “breadcrumbs” to its link weight).

Search robots index only the first - main - page, which they get to from third-party resources. Other pages remain closed to Yandex and Google - after all, even from other sites it is impossible to link to them due to the fact that frames hide the true addresses of the pages.

Promote one effectively home page today it is no longer possible - it is impossible to indicate all requests on it, and the PS will be much more suspicious of such a “one-pager”.

Of course, “traditional craftsmen” have already come up with a way to index internal pages by placing links to them in the frames’ installation document, and you can still find out the addresses by opening the frame page separately. But are all these complications necessary if, by abandoning such technologies, more can be achieved?

Areas of application of frames

Developers of HTML documents have a fairly wide choice of forms for displaying information on pages. Text and graphic information can be ordered and organized using lists, tables or simply using alignment options, setting horizontal lines, division into paragraphs. Sometimes these features are not enough and then you have to split the browser window into separate areas or frames. In a number of Russian-language descriptions of the HTML language, the term frames is used instead of the term frames. The frequency of use of both terms is approximately the same.

The choice of a frame structure for displaying information on the WWW is justified in the following cases:

  • if necessary, manage the loading of documents into one of the subareas of the browser viewing window while working in another subarea;
  • to locate information in a certain place in the viewing window that must always be on the screen, regardless of the content of other sub-areas of the screen;
  • to present information that is conveniently arranged in several adjacent sub-areas of the window, each of which can be viewed independently.

The given list does not exhaust all possible cases where frames can be applied, but is of a recommendatory nature.

Let's first consider typical uses of frames using examples of real-life HTML documents, and then turn to the rules for developing documents containing frames.

In Fig. Figure 5.1 shows one of the HTML pages of the Finmarket agency, which specializes in providing information from the financial and stock markets of Russia.

Rice. 5.1. A typical Web document with a frame structure

This page splits the browser window into three frames. The lower part of the window occupies 20% of the height of the entire window and contains permanent information, which in this case is a graphical menu that allows you to access the most important sections at any time. This frame cannot change its size based on user commands and does not have scroll bars. Top part window (80% of the height) is divided horizontally into two frames. The left frame contains the table of contents of documents that can be viewed by the user. The right frame, which occupies most of the viewing window, is intended to display the documents themselves. When initially loaded, these two frames split the browser window horizontally at a ratio of 15% to 85%. This ratio can be changed by the user during viewing, which allows you to select the optimal frame sizes taking into account the content of the loaded documents. Each of these frames has its own scroll bar, allowing you to view the entire contents of the frame, regardless of the size of the frame itself, the entire browser window, or the fonts used. When you select any link in the left frame, the corresponding document will be loaded in the right frame. This structure allows you to simultaneously see on the screen both the table of contents of documents and the contents of the selected document.

Here, without explanation, is a fragment of the HTML code used to build a document with this structure:

This example shows the most typical use of frame structures, where one frame serves as a table of contents for documents and another is used to load their contents. Solving such a problem without using frames is usually done as follows. On one of the pages there is a table of contents, consisting of links to other documents or their individual fragments. When you click on such a link, the table of contents disappears, and the required document is loaded in its place, after reading which you usually need to return to the table of contents. When using frames, this return becomes unnecessary, since the table of contents is always located on part of the screen.

You can find it on the Internet website of the electronic edition of the popular address and telephone directory "All Petersburg" in St. Petersburg.

The electronic version of the directory is available at http://www.allpetersburg.ru and allows you to find the necessary information based on user requests. This document page also has a frame structure and consists of two frames, the first of which is 100 pixels wide, and the second takes up the entire remaining width of the viewport. The frame located on the left side is used for a graphical menu that is constantly present on the screen, and also contains the Nevalink company logo. The second frame contains the document, which in this case is a user request form. The structure of this page is defined by the following HTML code:

Frames are very similar to tables - they both break up the browser window into rectangular areas in which some information is located. However, with the help of frames, you can solve not only the problem of formatting document pages, but also organize the interaction between them. The fundamental difference between frames and tables is that each frame must have its own separate HTML document, but the contents of all table cells are always part of the same document. In addition, the page displayed in the frame can scroll when viewed independently of the others. Each frame is essentially a separate "mini-browser". Unlike frames, the entire structure of which is always presented on the screen, tables may not completely fit in the window and can only be viewed in parts. It follows that if in HTML tables the total number of cells is practically unlimited and can reach several hundred, then the number of frames in a document usually does not exceed several units.

Advice

If you only need to format a document, then it is enough to limit yourself to using tables. If you need to solve more complex problems, for example, organize interaction between window subareas or create subareas that are permanently located on the screen, then it is convenient to use frames.

Ultimately, the choice of document structure - tabular or frame - depends on many factors and cannot be unambiguously predetermined.

There are alsopages that appear to be built similarly to the previous ones. For example, you can take page of a very popular collection all over the world software products, intended mainly for working with the Internet. Server address http://www.tucows.com. Note that the name of the server was determined by an abbreviation derived from the abbreviation of the full name of the collection - The Ultimate Collection of Winsock Software. Since the abbreviation tucows turned out to be consonant with the phrase two cows (two cows), the server pages often contain images of cows, and the rating of software products is estimated in the number of mooings (“Moo”) and is graphically depicted as a row of the corresponding number of cows. Most of the server pages are built in the same way - on the left side of the window there is a list of available sections, and on the right side there is a list of software products for the selected section. At first glance, the structure of the document should look approximately the same as in the previous examples. However, this document does not use frames! This page is built using a table that consists of just one row with two cells. The table has no frame and only serves the purpose of formatting the page. The impression of the screen being split vertically in two is created by using a background graphic containing a vertical line rather than a table grid. You can verify this by viewing the page without loading images. The use of a table here is apparently due to considerations of greater accessibility of documents, since frames do not allow display in all browsers.

The disadvantage of this approach in this case is the need to repeat the entire list of sections (left side of the page) in each document, which slightly increases the file size.

A comparison of the examples above shows that the use of tables and frames can sometimes be interchangeable and determined by the wishes of the developers. Note that often when looking at a page with a document displayed on it, it is impossible to determine how it is built. End user knowledge internal structure document is not required, however, when developing your own Web pages, familiarize yourself with source code existing documents would be extremely helpful. In the first example (see Fig. 5.1), the frame structure of the document is immediately visible - the presence of two vertical scroll bars already determines the presence of individual frames. The following two examples are very similar in appearance, and it is impossible to determine that the first of them is built using frames, and the second - using tables. Differences will only appear when working with them. In the example of a telephone directory, when scrolling a document, the left part of the window will remain in place, which is only possible if there is a frame structure. In the following example (a collection of software products), scrolling will shift the entire contents of the window.

You can view the document structure when working with the Netscape browser using the Page Info item (in versions 3.x of the Netscape browser this menu item was called Document Info) of the View menu (Fig. 5.2).

Rice. 5. 2 . Netscape Browser View Menu

In addition, you can always view the source HTML code of the entire document using the Page Source item of the View menu (or the View Frame Source item context menu(right-click to view the HTML code of the document loaded in the selected frame).

Advice

You should not unnecessarily abuse the use of frames, and their number should not exceed three or four.

Often on real pages on the Internet you can see the following cases of using frames:two adjacent frames are used to load documents that are convenient to view simultaneously and compare with each other. Each of the two documents loaded into frames uses a tabular form for presenting information. As a result of this organization of data, each of the two tables can be viewed (or printed) separately, or studied in comparison with the other.

All the examples given in this section are taken from the pages of popular WWW servers and, perhaps, can serve as examples of the use of frames in HTML documents.

Subsequent sections of this chapter cover rules for writing documents containing frames.

Rules for describing frames

Let us now move on to consider the rules for writing tags used for documents with frame structures.

Let's first look at the complete HTML code that creates a document with medium complexity frames:

</p> <p>

This example creates the framed page shown in Figure. 5.3. As you can see, this HTML code defines four frames. The top frame spans the entire width of the page and contains the heading. Next are two central frames, one of which is located on the left side and takes up 25 percent of the screen width, and the second takes up the remaining space. The last, fourth frame occupies the lower quarter of the screen. A separate HTML document is loaded into each frame, the name of which is determined by the SRC parameter.

As can be seen from the example, tags are used to describe the structure of frames , And . Let's look at the purpose of these tags.</p> <span> <br><img src='https://i2.wp.com/webnav.ru/books/html4/frames/07.gif' width="100%" loading=lazy loading=lazy></span> <p><i><b>Rice. 5. <span>3 . </b> The result of the Netscape browser displaying the HTML document with frames shown in the example</span> </i></p> <p><b>Tag <FRAMESET> </b></p> <p>Frames are defined in a structure called FRAMESET, which is used for pages containing frames, instead of the BODY section of a normal document. Web pages composed of frames cannot contain a BODY section in their HTML code. In turn, pages with a BODY section cannot use frames.</p> <p><i><b>Advice</b> </i></p> <p><i> <span>Since the BODY section is not used for pages with frames, there is no way to set <a href="https://gamevid.ru/en/ipod/dva-fonovyh-izobrazheniya-mnozhestvennye-fony-i-obvodka-s/">background image</a> and the background color for the entire page as a whole. Recall that these settings are determined by the BACKGROUND and BGCOLOR parameters written in the BODY tag. However, this does not prevent you from loading documents with their own background settings into each frame.</span> </i></p> <p>Container of tags <FRAMESET>And</FRAMESET> frames each frame definition block. Inside the container <FRAMESET>can only contain tags <FRAME>and nested tags <FRAMESET>. </p> <p>Tag <FRAMESET>has two parameters: ROWS (rows) and COLS (columns) and is written as follows:</p> <p><FRAMESET ROWS="список_ значений" COLS="список_ значений">. </p> <p><i><b>Note</b> </i></p> <p><i> <span>Some browsers allow additional tag parameters <FRAMESET></span> </i></p> <p>You can define values ​​for ROWS or COLS, or both. It is necessary to define at least two values ​​for at least one of these parameters. If another parameter is omitted, its value is assumed to be 100%.</p> <p><i><b>Advice</b> </i></p> <p><i> <span>If in a tag <FRAMESET>If only one value is defined for ROWS and COLS, then this tag will be considered invalid and the browser will ignore it. In other words, it is impossible to determine <FRAMESET>, consisting of only one frame.</span> </i></p> <p>List of tag ROWS and COLS parameter values <FRAMESET>is a comma-separated list of values ​​that can be specified in pixels, percentages, or relative units. The number of rows or columns is determined by the number of values ​​in the corresponding list. For example, record</p> <p><FRAMESET ROWS="100,240,140"> </p> <p>defines a set of three frames. These values ​​are absolute pixel values. In other words, the first frame (first row) is 100 pixels high, the second is 240 pixels, and the last is 140 pixels high.</p> <p>Setting frame size values ​​in pixels is not very convenient. This does not take into account the fact that browsers run in different <a href="https://gamevid.ru/en/ipod/mikroyadernye-operacionnye-sistemy-mikroyadernye-operacionnye-sistemy/">operating systems</a> and with different display resolutions. At the same time, it is possible to define absolute size values ​​for some cases, for example, to display a small image with known dimensions. <a href="https://gamevid.ru/en/reviews/sozdat-stranicu-vkontakte-novuyu-registraciya-bez-nomera-kak/">The best option</a> the values ​​will be specified in percentages or in relative units, for example:</p> <p><FRAMESET ROWS="25%,50%,25%">. </p> <p>This example creates three frames that are positioned as rows across the full width of the screen. The top row will take up 25 percent of the available screen height, the middle row will take up 50 percent, and the bottom row will take up 25 percent. If the sum of the specified percentages does not equal 100%, then the values ​​will be scaled proportionally so that the result is exactly 100%.</p> <p>The values ​​in relative units are as follows:</p> <p><FRAMESET COLS="*,2*,3*">. </p> <p>An asterisk (*) is used to divide space proportionally. Each star represents one part of the whole. By adding up all the values ​​of the numbers next to the asterisks (if a number is omitted, then one is assumed), we obtain the denominator of the fraction. In this example, the first column will take up 1/6 of the total width of the window, the second column will take up 2/6 (or 1/3), and the last will take up 3/6 (or 1/2).</p> <p>Remember that a numeric value without any characters specifies the absolute number of pixels for a row or column. A value with a percentage sign (%) specifies the proportion of the total width (for COLS) or height (for ROWS) of the viewport, and a value with an asterisk (*) specifies the proportional distribution of the remaining space.</p> <p>Here is an example that uses all three options for setting values:</p> <p><FRAMESET COLS="100,25%,*,2*">. </p> <p>In this example, the first column will be 100 pixels wide. The second column will take up 25 percent of the entire viewport width, the third column will take up 1/3 of the remaining space, and finally the last column will take up 2/3. It is recommended to assign absolute values ​​first in order from left to right. These are followed by percentages of the total space size. Finally, values ​​are recorded that determine the proportional division of the remaining space.</p> <p><i><b>Advice</b> </i></p> <p><i> <span>If you use absolute COLS or ROWS values, keep them small so they can fit in any browser window, and pad them with at least one percentage or relative value to fill the remaining space.</span> </i></p> <p>If the tag is used <FRAMESET>, in which both COLS and ROWS values ​​are specified, a grid of frames will be created. For example:</p> <p><FRAMESET ROWS="*,2*,*" COLS="2*,*"> </p> <p>This line of HTML code creates a frame grid with three rows and two columns. The first and last lines take up 1/4 of the height each, and the middle line takes up half. The first column takes up 2/3 of the width, and the second - 1/3.</p> <p>Container <FRAMESET> </FRAMESET> can be nested inside another similar container, as was shown in the initial example. Let's consider further the use of the tag <FRAME>. </p> <p><i><b>Note</b> </i></p> <p><i> <span>Some sources on the HTML language indicate that the COLS and ROWS parameters of the tag <FRAMESET>are mutually exclusive. However, both Netscape and Microsoft <a href="https://gamevid.ru/en/ipod/obnovlenie-internet-explorer-6-dlya-windows-xp-obnovlyaem-brauzer-internet/">Internet Explorer</a> allow their joint use.</span> </i></p> <p><b>Tag <FRAME> </b></p> <p>Tag <FRAME>defines a single frame. It must be located inside a pair of tags <FRAMESET>And</FRAMESET>. For example:</p> <p><FRAMESET ROWS="*,2*"> </p> <p><FRAME> </p> <p><FRAME> </p> <p></FRAMESET> </p> <p>Please note that the tag <FRAME>is not a container and unlike <FRAMESET>does not have an end tag. The entire definition of a single frame is done with one line of HTML code.</p> <p>There are so many tags to record <FRAME>how many individual frames are defined when specifying the tag <FRAMESET>. In the previous example, the tag <FRAMESET>two strings were given, so two tags needed to be written <FRAME>. However, this example is essentially useless, since none of the frames have any content!</p> <p>Tag <FRAME>has six parameters: SRC, NAME, MARGINWIDTH, MARGINHEIGHT, SCROLLING and NORESIZE.</p> <p><i><b>Note</b> </i></p> <p><i> <span>Some browsers allow you to use a number of additional tag parameters <FRAME>. An overview of the capabilities of the Netscape and Microsoft Internet Explorer browsers is given at the end of the chapter.</span> </i></p> <p>Here's the tag entry: <FRAME>with all parameters:</p> <p><FRAME SRC="url" NAME="window_name" SCROLLING=YES|NO|AUTO </p> <p>MARGINWIDTH="value" MARGINHEIGHT="value" NORESIZE></p> <p>In practice in the tag <FRAME>Rarely are all parameters used at the same time.</p> <p>The most important parameter is SRC (short for source). Quite often in the tag <FRAME>a single SRC parameter is specified. For example:</p> <p><FRAME SRC="url">. </p> <p>The value of the SRC parameter determines the URL of the document that will be loaded initially into this frame. Typically, this address is the name of an HTML file located in the same directory as the main document. Then the frame definition line will look, for example, like this:</p> <p><FRAME SRC="sample.htm">. </p> <p>Note that any HTML file specified in the frame definition must be a complete HTML document, not a fragment. This means that the document must have <a href="https://gamevid.ru/en/ipod/ispolzovanie-tega-footer-dlya-sozdaniya-podvala-na-stranice-novye-tegi/">HTML tags</a>, HEAD, BODY, etc.</p> <p>Of course, the SRC value can be any valid URL. If, for example, a frame is used to display an image in <a href="https://gamevid.ru/en/reviews/otkryt-fail-jpg-svg-onlain-iz-jpg-png-i-gif-v-format-svg-chem-konvertirovat/">GIF format</a>, which is located on the server of the publisher of this book, you should write:</p> <p><FRAME SRC="http://www.bhv.ru/example.gif">. </p> <p><i><b>Advice</b> </i></p> <p><i> <span>Do not include any content in the document describing the frame structure.</span> </i></p> <p>Plain text, headings, graphics, and other elements cannot be used directly in a document that describes a frame structure. All contents of frames must be defined in separate HTML files, the names of which are specified by the SRC parameter of the tag <FRAME>. </p> <p>The NAME parameter specifies a frame name that can be used to refer to this frame. Typically the link is set from another frame located on the same page. For example:</p> <p><FRAME SRC="sample.htm" NAME="Frame_1">. </p> <p>This entry creates a frame named "Frame_1" that can be referenced. For example:</p> <p>Click here to download</p> <p>document other.htm into a frame named Frame_1.</p> <p>Note the TARGET parameter, which refers to the frame name. If a frame is not given a name, an unnamed frame will be created and it will not be possible to reference it from another frame. Frame names must begin with an alphanumeric character.</p> <p>The MARGINWIDTH and MARGINHEIGHT parameters allow you to set the width of the frame margins. This is written as follows:</p> <p>MARGINWIDTH="value",</p> <p>where "value" is the absolute value in pixels. For example:</p> <p>This frame has margins at the top and bottom of 5 pixels, and on the left and right - 7 pixels. Remember that we are talking about margins here, not frames. The MARGINWIDTH and MARGINHEIGHT parameters define the space within the frame within which no information will be located. The minimum acceptable value for these parameters is one.</p> <p>Frames will automatically create and display scrollbars if the frame's contents do not fit entirely within the allocated space. Sometimes this breaks the design of the page, so it would be handy to be able to control the display of scrollbars. The SCROLLING parameter is used for these purposes. Recording format:</p> <p><FRAME SCROLLING="YES|NO|AUTO">. </p> <p>The SCROLLING parameter can take three values: YES, NO or AUTO. The AUTO value has the same effect as if there was no SCROLLING parameter. The value YES causes scroll bars to appear regardless of whether they are needed, and NO prevents them from appearing. For example:</p> <p><FRAME SCROLLING=YES>. </p> <p>Typically the user can resize frames as they view the page. If you place the mouse cursor on the frame frame, the cursor will take on a shape indicating the possibility of resizing and allow you to move the frame to the desired location. This sometimes breaks the structure of beautifully designed frames. To prevent the user from changing the size of frames, use the NORESIZE parameter:</p> <p><FRAME NORESIZE>. </p> <p>This parameter does not require any values. Naturally, when the NORESIZE parameter is set for one of the frames, then the size of any of the adjacent frames cannot be changed either. Sometimes, depending on the layout of the frames, using the NORESIZE parameter on one of the frames will be enough to prevent any of them from being resized on screen.</p> <p><b>Tag <NOFRAMES> </b></p> <p>The ability to work with frames was not intended in either the HTML 3.0 or HTML 3.2 standard. Here, until recently, there was a fairly typical situation when actually used features are actively used on many WWW pages, but are not part of the standard. This meant that browsers could legitimately ignore frames. With the advent of the HTML 4.0 standard, the situation has changed - now support for frame structures is enshrined in the standard. Note that most modern browsers recognized frames even before the advent of HTML 4.O. However, it is necessary to provide information to users using browsers that do not support frames. For such browsers, it is possible to provide alternative information that is written between a pair of tags <NOFRAMES>And. It looks like this:

</p> <p>entire HTML document</p> <p>

Everything placed between tags And, will be displayed by browsers that do not have frame support capabilities. Frame-aware browsers will ignore all information between these tags.

Note that in real life, HTML page developers often do not use the tag's capabilities to create pages without frame structures, but simply create two versions of their HTML documents. For this option <a href="https://gamevid.ru/en/instructions/nastroika-nachalnoi-stranicy-firefox-domashnyaya-startovaya-i-nachalnaya/">home page</a> Typically you are offered the choice of loading a document with or without a frame structure. Then, depending on the user’s choice, only one version of the document is loaded.</p> <p><b><span>Features of describing frame structures</span> </b></p> <p>One of the most important tags used when describing frame structures is the tag <FRAME>. A tag has a number of parameters, none of which are required or dependent on the others, but there are a number of things to consider when writing them.</p> <p>It turns out that if you need to create a frame into which a document can later be loaded, for example, by command from another frame, you should use the tag <FRAME>write the SRC parameter. If this</p> <p>the parameter is omitted, the frame will not be created, although space will be left for it. For example, a record like <FRAME NAME="B">is quite logical and could define a frame named "B" into which no document is initially loaded. However, due to the absence of the SRC parameter, a frame with that name will not exist, so further attempts to load any document into it will remain unsuccessful, and the space in the window allocated for this frame will be empty. Moreover, some browsers (for example, Microsoft Internet <a href="https://gamevid.ru/en/reviews/ne-mogu-obnovit-eksplorer-do-11-versii-obnovlyaem-brauzer-internet-explorer/">Explorer versions</a> 3 for Windows Z.xx) when trying to load a document into such a frame, an error message will be displayed and the work will terminate.</p> <p>The requirement for setting the SRC parameter cannot be explained logically, so it is best to simply take note of this fact. Then, even if there is no document that needs to be loaded into this frame from the very beginning, you should specify the name of a file in the SRC parameter. For example, such a file can be called empty.htm (empty), the contents of which will be the minimum possible correct HTML document, namely:</p> <p><HTML> </p> <p><HEAD> </p> <p></HEAD> </p> <p><BODY> </p> <p></BODY> </p> <p></HTML> </p> <p>Can be shortened <a href="https://gamevid.ru/en/repair/hranenie-metadannyh-v-excel-obekt-diapazona-udalenie-skrytyh-i-personalnyh/">this document</a> up to two tags: <HTMLX/HTML>, which will also be a valid HTML document. Following the path of maximally reducing the size of an “empty” document, you can limit yourself to a file whose size is equal to one byte, which stores the space character (or any other non-displayable character). This file will not be a valid HTML document, but will not cause problems with most browsers. Further reducing the size of such a file to zero is not justified, since when it is loaded by the Netscape browser, it will display a warning message (Fig. 5.4) that the document does not contain data.</p> <span> <img src='https://i2.wp.com/webnav.ru/books/html4/frames/08.gif' height="119" width="332" loading=lazy loading=lazy></span> <p><i><b>Rice. 5. <span>4 . </b> Warning message when uploading a zero-length file</span> </i></p> <p>In this case, you must respond to this message by pressing the key <Enter>or mouse button. Any time the document is reloaded or the browser window is resized, the message will appear again.</p> <p>You can also specify a name <a href="https://gamevid.ru/en/repair/kak-sozdat-arhiv-zip-s-parolem-kak-postavit-parol-na-arhiv-v-winrar/">existing file</a>, however, the Netscape browser will display a warning message (Fig. 5.5), which will not interfere with further work, but will lead to similar inconveniences.</p> <span> <img src='https://i2.wp.com/webnav.ru/books/html4/frames/09.gif' height="139" width="314" loading=lazy loading=lazy></span> <p><i><b>Rice. 5. <span>5 . </b> Warning message when trying to download a non-existent file</span> </i></p> <p><i><b>Advice</b> </i></p> <p><i> <span>Create a file called empty.htm that is one byte in size and contains a space character. Make it a rule when writing a tag <FRAME>always specify SRC=empty.htm if it is impossible to immediately specify the name of a specific file.</span> </i></p> <p>Examples of frames</p> <p>This section provides some typical examples of frame definitions.</p> <p>Let's return to the example given at the beginning of this section (Fig. 5.3). This example uses a nested structure <FRAMESET>. External tag <FRAMESET>creates three rows of height, respectively 25, 50 and 25 percent of the total height of the viewport:</p> <p><FRAMESET ROWS="25%,50%,25%">. </p> <p>Within this definition scope, the first and last lines are simple frames:</p> <p><FRAME SRC="header.htm"> <FRAME SRC="footer.htm"> </p> <p>Each of these lines fills the entire width of the screen. The first line at the top of the screen takes up 25 percent of the height, and the third line at the bottom also takes up 25 percent of the height. Between them, however, there is a nested tag <FRAMESET>: </p> <p><FRAMESET COLS="25%,75%"> </p> <p><FRAME SRC="list.htm"> </p> <p><FRAME SRC="info.htm"> </p> <p></FRAMESET> </p> <p>This tag defines two columns into which the middle row of the screen is divided. The row containing these two columns takes up 50 percent of the screen height, as defined in the outer tag <FRAMESET>. The left column uses 25 percent of the screen width, while the right column takes up the remaining 75 percent of the width.</p> <p>The frames for these columns are defined within a nested pair of tags <FRAMESET>And</FRAMESET>, while the definition of frames for the first and last line is written outside this pair, but inside the outer <FRAMESET>in the appropriate order.</p> <p>The record structure is easy to understand if you think of it as a nested block <FRAMESET>as a separate element <FRAME>. In our example, the outer tag <FRAMESET>defines three lines. Each of them must be completed. In this case they are filled in first <a href="https://gamevid.ru/en/repair/kak-proverit-cep-na-obryv-multimetrom-prozvonka-cepi-proveryaem/">separate element</a> <FRAME>, then - as a nested block <FRAMESET>two columns wide and then another element <FRAME>. </p> <p>Now the question may arise whether the value of the SRC tag parameter can be <FRAME>set the name of the file, which, in turn, contains a description of the frame structure. Yes, this is acceptable. In this case the tag <FRAME>will be used to point to an HTML document that is a frame structure and is used as a separate frame.</p> <p>Let's go back to the example and replace the nested <FRAMESET>to a separate <FRAME>. Naturally, you will need two HTML files instead of one, since nested <FRAMESET>will now be located in a separate document. Here is the contents of the first (external) file:</p> <p><HTML> </p> <p><HEAD> </p> <p></HEAD> </p> <p><FRAMESET ROWS="25%,50%,25%"> </p> <p><FRAME SRC="header.htm"> </p> <p><FRAME SRC="frameset.htm"> </p> <p><FRAME SRC="footer.htm"> </p> <p></FRAMESET> </p> <p><NOFRAMES> </p> <p>Your browser can't display frames</p> <p>

The second file, named frameset.htm, contains the following code:

In this case, the top and bottom lines behave the same. But the second line is now a simple frame like the others. However, the frameset.htm file pointed to by the SRC parameter defines its own frame structure. As a result, the screen will display exactly the same as in the original example.

Note

It is in principle possible to create nested structures , using tags , which refer to the same file describing the frame structure, but this should not be done. This situation will lead to endless recursion and will not allow further work. Some browsers control this situation and prevent the possibility of failure. If the address written to SRC matches one of the previous addresses in the frame hierarchy, then it is ignored, as if the SRC parameter were not present at all.

Advice

Using Nested Structures in various combinations, it is possible to create almost any frame grid imaginable. However, remember to create a user-friendly interface and not just demonstrate your ability to work with frames.

Here's an example of creating a regular rectangular grid of frames:

This example creates a frame grid with two rows and three columns (Figure 5.6). Since a set of six frames is defined, it is also necessary to define six individual frames . Please note that frame definitions are given line by line. That is, the first tag defines the contents of the first column in the first row, the second defines the contents of the second column, and the third finishes defining the data for the last column of the first row. The last three frames then fill the columns of the second row.


Rice. 5. 6 . 2 by 3 frame grid

Note also that the sum of the percentage values ​​in the COLS parameter is not 100, but only 90 percent. There is nothing wrong with this, since the browser will automatically proportionally change the width of the columns to eliminate this contradiction.

Features of navigation when using frames

Working with documents that have a frame structure has some features that you need to know. These features of JB are mainly manifested in navigation when loading documents. Significant differences in navigation are characteristic not only of different browsers, but also different versions the same browser.

The Netscape browser versions 3.x and 4.x, when you click the Back button, returns the document back to the frame that was last acted upon. The same actions will be performed if the Back item is selected when calling the context menu in any of the frames. Let us remind you that the context menu is called up by clicking the right mouse button. Thus, regardless of which frame the context menu was called in, pressing the Back button will cancel the last operation, even if it was performed in another frame.

The Netscape 2.x browser worked completely differently. The context menu contains the Back in Frame command, which returns the document to the current frame rather than undoing the last operation.

In any version of Netscape, you can bookmark a document contained in a selected frame. To do this, you need to select the Add Bookmark mode from the context menu mentioned above. If you simply select the Add Bookmark mode from the main menu of the browser, a bookmark will be made on the document with a description of the frame structure , which will not accurately point to a specific frame. The ability to create a bookmark on a document of a separate frame does not mean that the same frame structure will arise when you continue to use this bookmark. The document pointed to by the bookmark will be loaded into a full window outside the frame structure.

Interaction between frames

The simplest form of viewing information on the WWW consists of reading pages and following links, in which the current document in the browser window is replaced by another document. When working with frames, you can organize a more user-friendly document loading scheme.

Interaction between frames is the ability to load documents into the selected frame using commands from another frame. For this purpose, the TARGET tag parameter is used<А>. This parameter specifies the name of the frame or browser window into which the document pointed to by this link will be loaded. By default, if there is no TARGET parameter, the document is loaded into the current frame (or window). This default can be overridden by specifying a tag with the desired value of the TARGET parameter. Specifying the name of the default frame to load into is very useful when a large number of links need to direct documents to a specific frame. A typical situation with a table of contents in one frame, links from which load corresponding documents into an adjacent frame, was shown at the beginning of this chapter (Figure 5.1). For this example in the section file named LIST.htm, it is advisable to write the following line: . Otherwise, you would have to specify a TARGET parameter for each link.

Frame names must begin with a Latin letter or number. The name can be the name of an existing window or frame, or a new name can be specified under which a new window will be opened. There are four reserved names that perform special actions when specified. These names begin with an underscore (_): "_blank", "_self", "_parent", and "_top". Any other name that begins with an underscore is not valid.

TARGET="_blank" - ensures that the document is loaded into a new window. This window will not have a name, and therefore it will not be possible to load another document into it.

TARGET="_self" - the document will be loaded into the current frame (or window). This entry should be used to bypass the default specified by the tag .

TARGET="_top" - causes the document to load into the full window. If the document is already in a full window, then given value acts the same as"_self".

TARGET="_parent" - causes the document to be loaded into the area occupied by the parent frame of the current frame. If there is no parent frame, this parameter value has the same effect as"_top" .

Note

Some HTML sources erroneously state that if a frame has no parent, the value "_parent" is equivalent to "_self". This statement is not always correct.

Warning

The reserved frame names "_blank", "_self", "_parent" and "_top" must be written in lowercase Latin letters. Note that such exactingness is unique to Netscape. Microsoft Internet Explorer correctly recognizes reserved names written in any case.

Here are examples of interaction between frames and individual browser windows. Consider the following HTML code:

Using Frames

This HTML document describes a structure consisting of three frames named "A", "B" and "C". Frame names will be needed later to organize links between frames. Note that there will be no links to the frame with the name “A” in this example, so it could have been left without a name at all. When you load the above document into a browser, the frames will display the information contained in the files identified by the SRC parameter. Frame "A" will receive the contents of the frame_a.htm file, and the other two frames will receive data from the empty.htm file, which has no data to display. Let us remind you once again that the HTML document describing the structure of frames does not have a section .

Here is the text of the file named frame_a.htm:

Document for Frame A

D

4. Loading a document in a new window

5. Loading a document in full window

6. Loading a document into the current frame

This document is a complete HTML document with sections And and, in turn, has links to a file called test.htm, located in the same directory as the frame_a.htm file.

The text of the test.htm file is extremely simple:

Test document

Test document text

The file frame_a.htm, the contents of which were loaded into frame "A", has six links to the same file test.htm with different values ​​for the TARGET parameter.

Let's consider the actions that will occur when implementing these links. The first link with the value TARGET="B" will load the file test.htm into a frame named "in". Note that after implementing any of the six links, the Netscape browser will automatically color all six of them a different color, since they point to the same file. Microsoft Internet Explorer only marks links that are actually implemented.

The second link will do the same for frame "C". Initially, there is nothing in frames “B” and “C” (more precisely, the contents of the empty file empty.htm are loaded). The implementation of the first and second links will fill these frames.

The third link with the value TARGET=MD" will lead to the formation of a new browser window with the name "D" and loading the test.htm file into it. Note that the form of writing this link is no different from the first two. The difference is that in the first In two cases, references were given to existing frames, the names of which were defined in the file with the frame structure, and in this case the reference was given to a non-existent object. If this reference is made at least once, then a window with the name "D" will be created and repeated clicking on the link will only reload the data into the now existing window "D". Of course, the user can close it at any time and re-create it by selecting this link. Figure 5.7 shows the situation after the first three links have been implemented. Recall that the location and the sizes of windows on the screen are determined by the user.

Rice. 5. 7 . The situation obtained after sequential implementation of the first three links available in the left frame

The fifth link with the value TARGET="_top" will load the document in the full window instead of the entire frame structure. With this value of the TARGET parameter, a new window is not created. Returning to the frame structure is possible by clicking the Back button.

Note

The names of frames or browser windows should not be confused with the names of downloaded documents. The names of the frames are not visible anywhere when viewed; they are required only to organize interaction and are therefore hidden from the user. You can see them only when viewing the source text of HTML files.

Advice

Let us remind you that the names of downloaded documents are specified by the tag . If a document is loaded in a full window, its name is displayed at the very top of the browser window. If a document is loaded into a frame, then its name is not displayed anywhere, and the title of the document containing a description of the document’s frame structure will still be located in the upper part of the window. Therefore, the names of documents intended to be viewed in frames are not very important. For example, in Fig. 5.7 the same document is loaded into frames “B” and “C”, as well as into a separate window named “D”, while the name of the document is visible only in window “D”. However, it is hardly recommended to omit the names of documents loaded into frames, as they may appear, for example, in the Bookmarks list when creating a bookmark for a document located in a frame or list of viewed documents.</span> </i></p> <p>Let's look at another interesting example of organizing interaction between frames and browser windows. Let there be the text of the main loaded HTML document:</p> <p><HTML> </p> <p><HEAD> </p> <p><TITLE>Using window names

A document with a frame structure into a new window

Using Frames

Please note that if the main document is a standard HTML document, then the frame.htm file loaded from a link from the main document contains the frame structure and in turn links to the empty.htm file.

After loading the main document, the browser window will look like shown in Fig. 5.8 (left window). The entire document consists of two links. Let's follow the first link. A new window will be created with the name “D”, in which the text of the test.htm file will appear (Fig. 5.8, right window). Repeating this link will only reload the data in window "D".


Rice. 5.8. Example of interacting frame windows

Let's follow the second link. A new window will be formed without a name, into which the frame.htm file will be loaded, defining two frames with the names “C” and “D” (Fig. 5.8, bottom window). There is nothing in both frames (more precisely, an empty document empty.htm is loaded). Notice that there is now an open window named "D" and a window with frames, one of which is also named "D". Let's follow the first link again. Unlike the first case, data will be loaded not into window “D”, but into a frame named “D”. The result of all the described actions is shown in Fig. 5.8.

Note

The appearance of opening windows and their contents can sometimes even depend on the order of user actions. Working with documents whose behavior is difficult to predict usually causes justifiable irritation for the user and indicates a lack of thoughtfulness in the data structure by the developers.

If you change the order of actions, i.e. first execute the second link, and then the first, then the window named “D” will not appear at all! This will happen because after implementing the second link, a frame named "D" will be created and there will be no need to open a new window for the first link.

This example is not a role model at all, but only shows the possible complexity of organizing interaction. On the contrary, you should try not to unnecessarily complicate the organization of data, much less create situations in which the result changes depending on the order of the user’s actions.

Advice

Avoid collisions in frame and window names. Although it is not formally prohibited to have frames with the same names, it can lead to confusion.

Warning

Frame and window names are compared in a case-sensitive manner. So, for example, frames named "frame_1" and "Frame_1" will be different.

Examples of more complex interactions between frames

Quite simple typical examples of interaction between frames were discussed above. The tasks of creating new windows, replacing the contents of individual frames, as well as displaying a document in a full window with the destruction of the entire frame structure were considered. Examples are given of using custom frame names, as well as the reserved names "_blank", "_self" and "_top". Using the last reserved name "_parent" is more complex and will be described below.

This section will look at more complex options for interaction between frames. In particular, replacement of the contents of several adjacent frames will be implemented.

One of the most common uses of frames, which has already been mentioned in this chapter, is the case of two frames, one of which contains a list of links, and the other contains the documents themselves (Fig. 5.1).

Let's try to expand the formulation of the problem. Suppose you want to display on the screen the contents of a fairly large document consisting of chapters divided into sections. A typical example is technical literature on a particular topic. Let us describe the desired presentation of such a document on the screen. Let's divide the screen into three frames, one of which will contain a list of book chapters, the second - a list of sections of the selected chapter, and the third - the text of the selected section. When you select a link in the second frame, the contents of the third frame should change. The implementation of this requirement is trivial. When you select a link in the first frame, the contents of both the second and third frames should change simultaneously. At first glance, implementing this task in HTML is impossible (without using programming in JavaScript or others), since when a link is executed, only one document is loaded, and not two or more. Nevertheless, solving this problem is quite possible.

Let us show a possible solution to such a problem using a simple example. Suppose you want to display three frames on the screen and load some documents into them. Let's set the task of creating links in each of these frames, the implementation of which, for example, swapped the contents of two frames. Let the first frame take up 50% of the window's width and 100% of its height and position it on the left side of the window. The right half of the window is also divided horizontally in half and contains two other frames. This structure is described by the following code:

Using this HTML code, the required structure will be created, but solving the problem is impossible. It is necessary to remove the nested structure into a separate file, and in this HTML code describe a frame that refers to the created file. Then the text of the source document will look like:

Example of interaction between frames

Created file with nested structure has the name 1_2.htm and contains the following code:

1-2

At first glance, nothing has changed at all. In both cases there are three frames into which the documents left.htm, 1.htm and 2.htm are loaded respectively. However, when the frames interact, the difference will appear. If in the first case none of the frames has a parent frame, then in the second case for two frames the parent will be a frame named "Two_Frames". Therefore, if in any of two frames you apply a link with a TARGET parameter value equal to "_parent", then the result will be different for the first and second cases. For the first case, implementing such a link will load the document into a full window, replacing the existing frame structure. This is where the "_parent" value property comes into play, which acts like "_top" in the absence of a parent frame. In the second case, a frame named "Two_Frames" will be replaced, which occupies the right half of the screen and essentially consists of two frames.

The second case formally differs from the first also by the presence of a frame named "Two_Frames" to which references can be made. It is precisely this feature that will allow us to solve the problem.

Here is the contents of the left.htm file, which is initially loaded into the first of the frames under consideration:

Left frame

documents in two frames located on the right side of the window.

Select document location option:

1 _2.htm" TARGET="Two_Frames">Option 1-2

Option 2-1

2-1<TITLE> </p> <p></HEAD> </p> <p><FRAMESET ROWS="*,*"> </p> <p><FRAME SRC="2.htm"> </p> <p><FRAME SRC="1.htm"> </p> <p></FRAMESET> </p> <p></HTML> </p> <p>Note that the text of files 1_2.htm and 2_1.htm differ only in the order of links to files 1.htm and 2.htm.</p> <p>Let us now consider the construction of a document loaded into the left frame. It contains two links with the TARGET="Two_Frames" parameter. The implementation of any of these links creates two frames at the location of the “Two_Frames” frame (this is the right half of the screen), loading documents 1.htm and 2.htm in one order or another. Thus, when choosing option 1-2, document 1.htm is loaded into the upper right frame, and 2.htm into the lower right frame. When you select option 2-1, the order of the documents changes. As a result, the alternating selection of options creates the impression that the documents in the two frames are changing places. This is exactly the effect we sought to achieve (Fig. 5.9).</p> <p>The contents of documents 1.htm and 2.htm do not matter for the described example. However, for example, instead of trivial documents, we will create documents with links that implement the same actions.</p> <p>Text of file 1.htm:</p> <p><HTML> </p> <p><HEAD> </p> <p><TITLE>Document 1

Document 1

Option 1 -2

Option 2-1

File 2.htm differs from 1.htm only in the header.

There are two links with the value TARGET="_parent" that point to the parent frame. These links could also be written with an explicit name of the parent frame, i.e. TARGET="Two_Frames", but using an implicit name is usually more convenient. For example, if you exclude links from the left frame (document left.htm), you could omit the frame name "Two_Frames" specified when describing the main frame structure. This would create a frame with no name, but the links from documents 1.htm and 2.htm with TARGET="_parent" would still work correctly.

Advice

Whenever possible, use implicit frame naming. For example, "parent","top","self" instead of specifying specific names.


Rice. 5.9. Interacting frame windows with the effect of changing loaded documents

Difference between frames and browser windows

When working with frames, the question arises about the fundamental difference between organizing the frame structure of a browser window and creating multiple windows. At first glance, it might seem that you could get by with the ability to create multiple windows, since working with windows and frames is very similar. Each frame requires a separate document to be loaded, has the ability to scroll content independently, and can be modified by commands from other frames. These properties of frames are similar to those of browser windows. With a tabular organization of data, it is impossible to achieve such freedom of action.

However, there is a significant difference between frames and windows. With frame organization, the division of the viewing area into frames is performed by the HTML document itself, indicating the dimensions and their location. When viewing, the user can change the size of frames, unless this is prohibited in the description of their structure. The arrangement of windows is determined by the general rules of working with the Windows system - the user can expand any window to full screen, minimize it into an icon, or arbitrarily set its size and location. Windows, unlike frames, can overlap. This wealth of choice has its downside - you need to manually position windows on the screen each time and resize them to achieve the optimal viewing option. In the case of frames, the optimal size ratio is usually specified by the developer in the description of the frame structure and often does not need to be changed.

Advice

Although frames cannot provide all the possibilities for working with individual windows, their rational organization will create maximum convenience for the user.

Working with windows also has other disadvantages. Creating each window requires a lot of memory. In Netscape, each window is essentially another copy of the browser, complete with a full set of buttons and menus. The same situation is typical for Microsoft Internet Explorer.

Note that the organization of individual windows in browsers is done differently. Creating a new window with a document results in the appearance of a separate task in the Windows system, as you can see when viewing the list of running tasks. Therefore, switching between windows can be done in the same way as switching between different tasks, for example by pressing a keyboard shortcut +.

Many popular Windows applications have the concept of a document window. An example is text Microsoft processor Word or graphics program Paint images Shop Pro and many others. Each of these applications allows the simultaneous use of several windows with data and, as a rule, there is a Window menu, which provides a list of windows and gives the ability to switch between them. The creation of a new window in such applications usually occurs when opening an existing file or creating a new one. However, in these programs, when a new window is created, a new running task is not created.

Netscape also has a Window menu that lists existing windows. (In Netscape 4.x versions, this feature is provided by the Window item on the Communicator menu.) Let's return to Fig. 5.8. In this example, three windows are open at the same time, each of which is essentially a separate browser. However, for the user, they are all windows of the same browser that can interact with each other. In any of these windows, you can open the Window menu and see a list of three windows. In Fig. Figure 5.10 shows the situation when this is done for the bottom window.


Rice. 5.10. Opening Frame Windows in the Netscape Browser

Each window can be closed separately (using the Close command from the File menu). To finish working with the browser in any window, you can open the File menu and select Exit (Fig. 5.11).

If several windows were open, then all of them will be closed, but before this a warning message will appear (Fig. 5.12).

Each browser window can have its own settings (though not all). Look at fig. 5.11. Two windows are open, one of which is divided into three frames. The same document is loaded in two of the three frames, as well as in a separate window. The ability to independently configure the parameters of each window allows you to display the same document differently. In the example above, the font size of the document in one window is larger than in the other. This effect is achieved by setting different encodings for each window (the Document Encoding item of the Options menu or the Character Set item of the View menu for version 4.x), with both encodings using the same font, but of different sizes. Changing any item in the General Preferences menu affects all windows.


Rice. 5.11. Quitting the Netscape Browser

Rice. 5.12. Warning about closing windows in the Netscape browser

Additional browser features

All of the above frame description tags with the corresponding parameters are implemented almost identically in the Netscape and Microsoft Internet Explorer browsers, however, each of these browsers allows you to additionally use its own unique tags or parameters.

Netscape Browser Features

The Netscape browser, starting with version 3.0, allows three additional options: BORDER, FRAMEBORDER, and BORDERCOLOR. The BORDER parameter applies only to the tag . The value of the BORDER parameter determines the thickness of the borders between frames in pixels.

The FRAMEBORDER parameter can be used both in the tag , and in the tag and determines the presence of a frame between frames. This parameter can be Yes or NO. If the parameter is written in the tag , then its effect applies to all frames in this group. For an individual frame, the value can be overridden. The default value is Yes.

Note that the BORDER and FRAMEBORDER parameters operate independently of each other. For example, if FRAMEBORDER is set to NO and BORDER is set to a value other than zero, then the border between the frames will not be drawn, but the space for it will be defined by value BORDER parameter will still be allocated.

The BORDERCOLOR parameter can be used as in the tag , and in the tag and defines the border color, which can be specified by the color name or its hexadecimal representation.

Here's an example:

The first line of this HTML code specifies three frames, with space between them for a 10-pixel thick frame (Figure 5.13).


Rice. 5.13. Drawing borders between frames in the Netscape browser

Between frame windows "A" and "B", no frame is drawn due to the NO value of the FRAMEBORDER parameter, however, the color red is defined for the frame. For the last frame "c", the FRAMEBORDER value is set to Yes and overrides the value set on the first line. Therefore, between the frames named “B” and “C”, a red frame with a thickness of 10 pixels will still be drawn.

Note

If borders between frames are not drawn, the Netscape browser will not allow frames to be resized by dragging them with the mouse, even without the NORESIZE parameter. For Microsoft Internet Explorer the situation is different.

Note that frames without borders are not used very rarely. It should be remembered that the absence of frames does not prevent the appearance of scroll bars (Fig. 5.14).


Rice. 5.14. Scrollbars in frame without borders

Microsoft Internet Explorer Browser Features

The Microsoft Internet Explorer browser allows you to use the FRAMEBORDER parameter for the same purposes as described above, but does not allow you to set the color and thickness of the frames. However, only the numeric value "O" can be used as a value for the FRAMEBORDER parameter to cancel drawing a frame, or a non-zero numeric value to draw a frame.

The difference in the rules for setting the values ​​of the FRAMEBORDER parameter for different browsers very unpleasant. Try, for example, setting FRAMEBORDER=Yes. This entry is correct for Netscape, but for Microsoft Internet Explorer it will result in the absence of a frame. The previous example (Fig. 5.13) when viewed in Microsoft Internet Explorer will be presented without a frame.

Advice

It is recommended to always write the value of the FRAMEBORDER parameter in numeric form, for example, FRAMEBORDER=0. This follows the rules for writing a parameter for Microsoft Internet Explorer, but violates the rules for Netscape (although it is correctly perceived by the latter).

Note

If the frames between the frames are not drawn, then the Microsoft Internet Explorer browser (unlike Netscape), in the absence of the NORESIZE parameter, will allow you to “touch” resize the frames by dragging the frames with the mouse. You can find the place where the frame should be by changing the shape of the mouse pointer.

The Microsoft Internet Explorer browser allows the use of an additional FRAMESPACING parameter written in the tag , the value of which determines the number of pixels between frames to be left blank.

Let us give an example, the display result of which is shown in Fig. 5.15.

Changing the distance between frames


Rice. 5.15. Empty space between frames in Microsoft Internet Explorer

Note

Unfortunately, many HTML language descriptions erroneously state that the FRAMESPACING parameter must be used in the tag . Microsoft Internet Explorer only allows this parameter to be used in a tag .

Floating frames

Microsoft Internet Explorer browser allows the use of a unique tag . In TEGS

Microsoft Internet Explorer is the first browser (and so far the only one) that supports so-called "floating" frames.

These frames can be placed anywhere on the screen, just like graphics and tables.

The frame to the right of this text is placed on the page using a special tag