home - Setting up the router
Inserting a frame. Creating Frames

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 parameters, setting horizontal lines, and dividing 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. The top part of the window (which is 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 worldwide collection of software products designed primarily 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. The end user does not need to know the internal structure of the document, but when developing his own Web pages, familiarization with the source code of existing documents would be extremely useful. 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 HTML source code of the entire document by using the Page Source item of the View menu (or the View Frame Source item of the right-click context menu 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://i1.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 framed pages do not have a BODY section, there is no way to set a background image and background color for the entire page. 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 on different operating systems 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. The best option would be to set the values ​​in percentages or 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 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 Internet Explorer allow them to be used together.</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 HTML, HEAD, BODY, etc. tags.</p> <p>Of course, the SRC value can be any valid URL. If, for example, the frame is used to display a GIF image that is located on the server of the publisher of this book, then 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 borders. 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, the start page usually offers 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 Explorer version 3 for Windows Z.xx) will display an error message and exit when trying to load a document into such a frame.</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>You can reduce this document 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://i0.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 the name of a non-existent file, but in this case the Netscape browser will display a warning message (Fig. 5.5), which will not prevent 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 first with a separate element <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 of different versions of 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 this value has the same effect 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 remaining 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. Examples include the Microsoft Word word processor or the graphics program Paint 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 frames will not be drawn, but the space specified by the BORDER parameter value will still be allocated for it.

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 is 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 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

Example document with floating frame:



floating frame


floating frame


The so-called "floating frame" has been introduced into this page.
In a separate window, it opens another html document for display.



… … …




Noframes

Some browsers do not support the document frame structure or interpret it incorrectly; in addition, users often deliberately disable support for the HTML document frame structure in their browser settings. And although the percentage of such browsers and users is small, they nevertheless exist.

Now imagine that you have built your website using a frame structure and some visitors, perhaps without knowing what the problem is, try to open your website, and their browser displays an error! What will they think of your site? I think something like: “Ugh.. some kind of nonsense.. I won’t come here again!”

In order to make it clear to the user that his browser/browser settings do not support frames, there is a tag </b> .</p> <p>Tag <b><noframes> </b> displays the text enclosed in it if the user's browser does not support frames or they are forcibly disabled in its settings. If frames are supported by the user's browser, then this tag is simply ignored.</p> <p> <html> <br> <head> <br> <title>frames</title> <br> </head> <br> <frameset cols="*,800,*" border="0"> <br><b><noframes>Sorry, but your browser does not support frames..











The result of the example will be noticeable if your browser really does not support frames (here I thought for a long time.. :) if this is so, then why read this chapter at all?) or you turned off frame support in your browser as an experiment.

Tag </b> must be located inside a tag <b><frameset> </b></p> <p>With a floating frame, everything is even simpler, just write the desired text between <b><iframe> </iframe> </b> and this message will be displayed on the screen if the browser does not support frames.</p> <p> <iframe src="primer.html" width="300" height="250" align ="left" scrolling="auto" frameborder="1"><b>Sorry, but your browser does not support frames..</b></iframe> </p> <ul><p>Before you start creating a page using a frame structure, analyze its layout, the size of each window, the presence or absence of scroll bars in them, etc. After this, you can create plug-in HTML files without particularly worrying about their relative position relative to each other.</p><p>Use tag <b><noframes> </b>. Remember that if in your browser the site works and is displayed as you intended, then for other users things may be different!</p> </ul> <p>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.</p> <p>The tag is used to create a frame <frameset>, which replaces the tag <body>in a document and is used to divide the screen into areas. Inside this tag there are tags <frame>, which point to the HTML document intended to be loaded into the area (Figure 13.1).</p> <p>Rice. 13.1. Example of splitting a browser window into two frames</p> <p>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.</p> <p>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).</p> <p>Example 13.1. index.html file</p><p> <!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=utf-8"> <title>Frames</title> </head> <frameset cols="100,*"> <frame src="menu.html" name="MENU"> <frame src="content.html" name="CONTENT"> </frameset> </html> </p><p>If frames are used, the following document type is written in the first line of code.</p><p> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd"> </p><p>The<!DOCTYPE>tells the browser that it is dealing with frames, this line of code is required. Container <head>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.</p> <p>In this example, the browser window is split into two columns using the cols attribute, with the left column taking up 100 pixels and the right column taking 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.</p> <p>In the tag <frame>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.</p> <p>Example 13.2. File menu.html</p><p> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Site navigation</title> </head> <body style="background: #f0f0f0"> <script type="text/javascript"> <!-- var _acic={dataProvider:10};(function(){var e=document.createElement("script");e.type="text/javascript";e.async=true;e.src="https://www.acint.net/aci.js";var t=document.getElementsByTagName("script")[0];t.parentNode.insertBefore(e,t)})() //--> </script><br> <br> </body> </html> </p><p>In this example, the gray background on the page is set using styles, which will be discussed later.</p> <p>Example 13.3. File content.html</p><p> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Site content</title> </head> <body> <p>CONTENT</p> <script type="text/javascript"> <!-- var _acic={dataProvider:10};(function(){var e=document.createElement("script");e.type="text/javascript";e.async=true;e.src="https://www.acint.net/aci.js";var t=document.getElementsByTagName("script")[0];t.parentNode.insertBefore(e,t)})() //--> </script><br> <br> </body> </html> </p><p>Let's consider a more complex example with three frames (Fig. 13.2).</p> <p><img src='https://i0.wp.com/htmlbook.ru/files/images/samhtml/fig_1_13_2.png' width="100%" loading=lazy loading=lazy></p> <p>Rice. 13.2. Dividing a page into three frames</p> <p>In this case, the tag is used again <frameset>, 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).</p> <p>Example 13.4. Three frames</p><p> <!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=utf-8"> <title>Frames</title> </head> <frameset rows="25%,75%"> <frame src="top.html" name="TOP" scrolling="no" noresize> <frameset cols="100,*"> <frame src="menu.html" name="MENU"> <frame src="content.html" name="CONTENT"> </frameset> </frameset> </html> </p><p>As can be seen from this example, the container <frameset>with the rows attribute first creates two horizontal frames, but replaces the second frame with another one <frameset>, 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.</p> <p><i> </i> 07.12.2015</p> <p>Not yet</p> <br><p>Hi all! <br>We continue to diligently study the basics of HTML. I'm glad you don't give up your lessons.</p> <p>In this lesson we will look at <b>what are frames</b> and how they are created in HTML. <br>So, let's define what frames are in HTML. <br><b>Frames</b>- This is the division of the browser window into separate areas in which individual HTML documents can be loaded.</p> <p>I think you understand that thanks to frames, you can view several web pages at once in one browser window.</p> <p>As an example, to understand how the frame works in practice, I suggest looking at an example. Make a couple of transitions there:</p> <p>So what do you think? Do you want to learn how to create this? Now we will learn <b>insert frames into html document</b>.</p> <p>A frame on a web page is created using the following layout:</p><p> <frameset> <frame> <frame> </frameset> </p><blockquote><p><b>Attention:</b> the frame code layout is inserted into the html document instead of the tag <bode><script type="text/javascript"> <!-- var _acic={dataProvider:10};(function(){var e=document.createElement("script");e.type="text/javascript";e.async=true;e.src="https://www.acint.net/aci.js";var t=document.getElementsByTagName("script")[0];t.parentNode.insertBefore(e,t)})() //--> </script><br> <br> </body> :</p> </blockquote> <html> <head> <title>Frames</title> </head> <frameset> <frame> <frame> </frameset> </html> <p>○ <b>frameset tag</b></p> <p>This is the main container for creating a frame, within which other elements are contained. <br>The closing tag is required.</p><p> <frameset></frameset> </p><p><i><b>*Attributes of the frameset tag:</b> </i> </p> <ul><li>Cols - vertical</li> <li>Rows - horizontal</li> </ul><p><b>rows</b>- horizontally</p> <p><img src='https://i2.wp.com/stepkinblog.ru/wp-content/uploads/2015/12/stepkinblog-ru-frameset-html-1.png' height="125" width="181" loading=lazy loading=lazy></p> <p><b>cols</b>- vertically</p> <p><img src='https://i0.wp.com/stepkinblog.ru/wp-content/uploads/2015/12/stepkinblog-ru-frameset-html-2.png' height="127" width="185" loading=lazy loading=lazy></p> <p>The cols and rows attributes indicate how many parts the browser window should be divided into. For example, to divide the browser window into two vertical parts, you need to write like this:</p><p> <frameset cols="30%,*"> </p><p>The left side of the screen will be 30% in size, and the right side will be 70%.</p> <p>If you want to divide the browser into several more parts, add additional dimensions separated by commas, for example, like this:</p><p> <frameset cols="30%,20%,10%,40%"> </p><p>As a result, the first <span>vertical column</span> will be 30% wide, the second - 20%, the third - 10%, the fourth - 40%.</p> <p><img src='https://i0.wp.com/stepkinblog.ru/wp-content/uploads/2015/12/stepkinblog-ru-frameset-html-3.png' width="100%" loading=lazy loading=lazy></p> <p>Got it?</p> <p>The same goes for the horizontal layout:</p><p> <frameset rows="30%,20%,10%,40%"> </p><p>The first horizontal column will be 30% wide, the second - 20%, the third - 10%, the fourth - 40%.</p> <p><img src='https://i1.wp.com/stepkinblog.ru/wp-content/uploads/2015/12/stepkinblog-ru-frameset-html-4.png' height="199" width="390" loading=lazy loading=lazy></p> <p>○ <b>frame tag</b></p> <p>The frame tag specifies which HTML document should be loaded into the browser window. <br>For example, we need to load three different pages “1.html”, “2.html”, “3.html” in one browser window. The frame tag will look like this:</p><p> <frame src="1.html"> <frame src="2.html"> <frame src="3.html"> </p><p>Let's summarize the knowledge on frames. So, the task: you need to divide the browser window into two parts and load two web pages into these parts - “1.html” by 30%, “2.html” by 70%. <br>Here is the finished code:</p><p> <frameset cols="30%,*"> <frame src="1.html"> <frame src="2.html"> </frameset> </p><p>The result will be like this:</p> <p><img src='https://i0.wp.com/stepkinblog.ru/wp-content/uploads/2015/12/stepkinblog-ru-frameset-html-5.png' width="100%" loading=lazy loading=lazy></p> <p><i><b>* Frame tag attributes</b> </i> </p> <ul><li>src – web page address. <i>src="1.html"</i> ;</li> <li>marginwidth – margin inside the frame along the width. Example: <i>marginwidth="10"</i> ;</li> <li>marginhight – height margin inside the frame. Example: <i>marginhight="10"</i> ;</li> <li>scrolling – scrolling the frame through the scroll. <br>- yes – the scroll will be present in the frame. Example: <i>scrolling="yes"</i> ;<br>- no – scroll will not be present in the frame. Example: <i>scrolling="no"</i> ;<br>- auto – scroll will be present in the frame if necessary. Example: <i>scrolling="auto"</i> ;</li> <li>noresize – prohibits moving frame borders.</li> <li>name – frame name. Specifies in which window other frames should be opened. Example: <i>name = "site"</i> ;</li> </ul> <p>If you do not specify a name for the frame in the “name” attribute, then when you click on the link, a new frame will open in the window where the link was:</p> <p>Here is an example if you add the “name” attribute:</p> <p>Isn't that better? <br>For any frame, add the “name” attribute where you want other HTML documents to open in it</p><p> <frame src="2.html "name ="сайт"> </p><p>The name in the “name” attribute can be anything. But in the future, if you give names to other “frame” tags, remember that each one must be unique:</p><p> <frame src="2..html "name ="bloggood-ru"> <frame src="3.html "name ="nocrisise-ru"> </p><p>page 2 page 3</p><p>“Page 1”, “Page 2” will open in one window where you specified the name for the frame “name =" <span>website "</span>" and "Page 3" will open in another frame, where the name "name =" <span>bloggood-ru "</span>»</p> <p><b>PRACTICE</b></p> <p>Task: You need to create frames using this layout:</p> <p><img src='https://i0.wp.com/stepkinblog.ru/wp-content/uploads/2015/12/stepkinblog-ru-frameset-html-6.png' width="100%" loading=lazy loading=lazy></p> <p>First, let's create three horizontal frames:</p><p> <frameset rows="15%,*,15%"> </frameset> </p><p>Now let's add "top.html" and "footer.html"</p><p> <frameset rows="15%,*,15%"> <frame src="top.html"> <frame src="footer.html"> </frameset> </p><p>The result so far will be like this:</p> <p><img src='https://i1.wp.com/stepkinblog.ru/wp-content/uploads/2015/12/stepkinblog-ru-frameset-html-7.png' width="100%" loading=lazy loading=lazy></p> <p>Now between “top.html” and “footer.html” we will add “menu.html” and “content.html”:</p><p> <frameset rows="15%,*,15%"> <frame src="top.html"> <frameset cols="25%,75%"> <frame src="menu.html"> <frame src="content.html" name="main"> </frameset> <frame src="footer.html"> </frameset> </p><p>Ready code:</p><p> <html> <head> <title>Frames</title> </head> <frameset rows="15%,*,15%"> <frame src="top.html"> <frameset cols="25%,75%"> <frame src="menu.html"> <frame src="content.html" name="main"> </frameset> <frame src="footer.html"> </frameset> </html> </p><p>Save the file as "index.html"</p> <p>Create the pages “top.html”, “footer.html”, “menu.html” and “content.html”:</p> <p>File code "top.html"</p><p> <html> <head> <title>site header</title> </head> <body bgcolor="#b2f2ff" text="#0000FF"> <h1>website</h1> <script type="text/javascript"> <!-- var _acic={dataProvider:10};(function(){var e=document.createElement("script");e.type="text/javascript";e.async=true;e.src="https://www.acint.net/aci.js";var t=document.getElementsByTagName("script")[0];t.parentNode.insertBefore(e,t)})() //--> </script><br> <br> </body> </html> </p><p>Code of the file "footer.html"</p><p> <html> <head> <title>File footer.html</title> </head> <body bgcolor="#b2f2ff" text="#000000">StepkinBlog.com © 2015<script type="text/javascript"> <!-- var _acic={dataProvider:10};(function(){var e=document.createElement("script");e.type="text/javascript";e.async=true;e.src="https://www.acint.net/aci.js";var t=document.getElementsByTagName("script")[0];t.parentNode.insertBefore(e,t)})() //--> </script><br> <br> </body> </html> </p><p>File code "menu.html"</p><p> <html> <head> <title>File menu.html – site menu</title> </head> <body bgcolor="#b2bbff" text="#112cf5"> <ul> <li>Home page</li> <li>about the author</li> </ul> <script type="text/javascript"> <!-- var _acic={dataProvider:10};(function(){var e=document.createElement("script");e.type="text/javascript";e.async=true;e.src="https://www.acint.net/aci.js";var t=document.getElementsByTagName("script")[0];t.parentNode.insertBefore(e,t)})() //--> </script><br> <br> </body> </html> </p><p>Code of the file "content.html":</p><p> <html> <head> <title>Home page</title> </head> <body bgcolor="#e3e5f8" text="#FF0055"> <h1>Home page</h1>Site content - "Home page (content.html)"<script type="text/javascript"> <!-- var _acic={dataProvider:10};(function(){var e=document.createElement("script");e.type="text/javascript";e.async=true;e.src="https://www.acint.net/aci.js";var t=document.getElementsByTagName("script")[0];t.parentNode.insertBefore(e,t)})() //--> </script><br> <br> </body> </html> </p><p>Code of the file "autor.html":</p><p>This is the result I got:</p> <p>Let’s use the “frame” attributes and disable manual stretching of frames and remove scrolling in the “index.html” file.</p><p> <frameset rows="15%,*,15%"> <frame src="top.html" scrolling ="no" noresize> <frameset cols="25%,75%"> <frame src="menu.html"scrolling ="no" noresize> <frame src="content.html" name="main"scrolling ="no" noresize> </frameset> <frame src="footer.html" noresize> </frameset> </p><p><b>○ what to do if frames are not supported by the browser? <br></b><br>You can display a message to the user that their browser does not support frames. To do this, insert the tag <noframes>inside the structure <frameset> :</p><p> <frameset rows="15%,*,15%"> <noframes>

○ Floating frame

If you need to insert an iframe window directly into a page that does not have a frame structure, there is an "iframe" tag for this.

* “iframe” tag attributes

  • src - path to the page to open
  • width - width of the floating frame
  • height - floating frame height
  • scrolling - scroll bar
    - no - never show the scrollbar
    - yes - always show
    - auto - show if necessary
  • align - floating frame alignment
    - left – left
    - right – on the right
    - top – higher
    - bottom – below
  • frameborder - border around floating frame
    - 1 - turn on the frame
    - 0 - turn off the frame

This is what the “iframe” tag with attributes will look like:

If your browser doesn't support frames, you can insert the text " OOPS! Your browser does not support frames. » between tags .
It will look like this:

For example, let's add an iframe to the "content.html" file:

Home page

Home page

Site content - "Home page (content.! Your browser does not support frames.

Previous post
Next entry



 


Read:



Rating of the best wireless headphones

Rating of the best wireless headphones

Is it possible to buy universal ears inexpensively? 3,000 rubles - is it possible to buy high-quality headphones for that kind of money? As it turned out, yes. And speech...

The main camera of a mobile device is usually located on the back of the body and is used for taking photos and videos

The main camera of a mobile device is usually located on the back of the body and is used for taking photos and videos

An updated version of the tablet with improved characteristics and high autonomy. Acer smartphones are rarely visited...

How to switch to another operator while keeping your number

How to switch to another operator while keeping your number

The law on preserving a telephone number when a subscriber switches to another mobile operator came into force in Russia on December 1. However, it turned out that...

review of a phablet, expensive, but very competent

review of a phablet, expensive, but very competent

Review of a phablet, expensive, but very competent 03/20/2015 I am the only shoemaker in the world without boots, a smartphone reviewer without my own smartphone....

feed-image RSS