今天是阳历 2024 年 05 月 06 日 星期一 农历 三月月 廿八日

 

[Online Resource Centre 教学材料]   [E-Teacher 电子教师]   [Homepage Constructions 网页建设 ]
 

Frames

No Frames

Simple Examples | No Frames | Borders and Borderless Frames | Nested Framesets | Frame Margins | Naming Frames & Targeting Links | Frames Exercise

What happens if someone who uses an old browser that doesn't support frames visits a page that uses frames? Since HTML browsers usually ignore what they don't understand, it's probably not surprising to learn that the old broswer should ignore everything inside the <frameset>...</frameset> container. (The only thing that should be inside the container is a set of frame tags that the browser also will not understand and will therefore ignore). Consequently, unless you plan ahead for such a browser, its user wouldn't see anything on the page.

This really should be problem that you no longer need to contend with. If someone has a browser so old that it does not support frames, he really should update to a newer browser. (The old browser probably also doesn't support a lot of other features that have become common in the last several years, so this user is probably missing out on a lot of what the web now has to offer.) Still, for the sake of comprehensiveness, we note that there is something you can do with your web pages to make sure that such old browsers at least see something there.

You can provide alternate content that will be visible to a visitor with an ancient browser by placing that content between <noframes> and </noframes>. Newer browsers that know what to do with frames also know to ignore anything inside <noframes>...</noframes>, so they won't display this material. The old browsers that don't understand frames also won't understand <noframes> or </noframes>, so they'll ignore the noframes tag. But they won't necessarily ignore what's between <noframes> and </noframes>. At a very minimum you can put a message there to the effect that the page uses frames and that the user's browser isn't frames-ready. The old browser should display this message. (Including at least a boilerplate statement along these lines is in fact a good idea as a courtesy to visitors who still may be using old browsers. That way the user won't just keep staring at an empty browser window, waiting for something that is never going to show up.) You might also want to include in your noframes section a friendly encouragement for the user to upgrade to a newer, frames-capable browser.

If you want to be more industrious, you can even include in the noframes section an alternative version of your page that doesn't use frames, or a link to a version of the page that doesn't use frames. If you decide to create alternative nonframe versions of your page(s) for these older browsers, you should be wary of what sort of elements you put on those pages. It's probably wise to stick to just text and simple images for such alternative pages. Again, most likely a browser that can't handle frames probably also can't handle a lot of other web goodies that have been developed since frames first began to be supported.

Alternative Ways to Size Frames

Here's a variation on our first example. In this case we only specify the size of the top frame (again 20%); the bottom frame takes whatever space is left in the browser window: Example 1a. The HTML code in this case is:

<frameset rows="20%,*">
<frame src="file1.html">
<frame src="file2.html">
</frameset>

The * value in the list of row sizes here indicates that the corresponding frame should occupy however many rows are left in this window.

We can also choose to specify frame widths and heights in terms of a specific number of pixels. For example, we could have specified the frame set of Example 1 with:

<frameset rows="80,320">
<frame src="file1.html">
<frame src="file2.html">
</frameset>

Since the frame set shown in Example 1 opens in a fixed (unresizable) browser window that is 400 pixels tall, this last specification should produce a frame set, Example 5, that is identical to the one in our first example.

Finally, what happens if we specify the dimensions of all our frames in percentages, but we aren't that careful with our math so the sum of the percentages that we specify for all the rows or columns turns out to be more than 100%? Then all the percentages will be uniformly rescaled by the browser so that the total is 100%. A similar thing happens if the total of our specified values is less than 100%.

 
[Online Resource Centre 教学材料]   [E-Teacher 电子教师]   [Homepage Constructions 网页建设 ]
      School Name 学校名称
      Online Resource Information 线上资源资讯
      News & Events 学校新闻
      Events Calendar 每日事件