通过使用框架,你可以在同一个浏览器窗口中显示不止一个页面。

实例,

垂直框架,本例演示:如何使用三份不同的文档制作一个垂直框架。

<html>

<frameset cols="25%,50%,25%">

<frame src="/example/html/frame_a.html">
<frame src="/example/html/frame_b.html">
<frame src="/example/html/frame_c.html">

</frameset>

</html>

效果:

水平框架,本例演示:如何使用三份不同的文档制作一个水平框架。

<html>

<frameset rows="25%,50%,25%">

<frame src="/example/html/frame_a.html">
<frame src="/example/html/frame_b.html">
<frame src="/example/html/frame_c.html">

</frameset>

</html>

效果:

框架,

通过使用框架,你可以在同一个浏览器窗口中显示不止一个页面。每份HTML文档称为一个框架,并且每个框架都独立于其他的框架。

使用框架的坏处:

  • 开发人员必须同时跟踪更多的HTML文档
  • 很难打印整张页面
框架结构标签(<frameset>)
  • 框架结构标签(<frameset>)定义如何将窗口分割为框架
  • 每个 frameset 定义了一系列行
  • rows/columns 的值规定了每行或每列占据屏幕的面积

编者注:frameset 标签也被某些文章和书籍译为框架集。

框架标签(Frame)

Frame 标签定义了放置在每个框架中的 HTML 文档。

在下面的这个例子中,我们设置了一个两列的框架集。第一列被设置为占据浏览器窗口的 25%。第二列被设置为占据浏览器窗口的 75%。HTML 文档 “frame_a.htm” 被置于第一个列中,而 HTML 文档 “frame_b.htm” 被置于第二个列中:

<frameset cols="25%,75%">
   <frame src="frame_a.htm">
   <frame src="frame_b.htm">
</frameset>

基本的注意事项 – 有用的提示:

假如一个框架有可见边框,用户可以拖动边框来改变它的大小。为了避免这种情况发生,可以在 <frame> 标签中加入:noresize=”noresize”。

为不支持框架的浏览器添加 <noframes> 标签。

重要提示:不能将 <body></body> 标签与 <frameset></frameset> 标签同时使用!不过,假如你添加包含一段文本的 <noframes> 标签,就必须将这段文字嵌套于 <body></body> 标签内。(在下面的第一个实例中,可以查看它是如何实现的。)

更多实例,

如何使用 <noframes> 标签,本例演示:如何使用 <noframes> 标签。

<html>

<frameset cols="25%,50%,25%">
<frame src="/example/html/frame_a.html">
<frame src="/example/html/frame_b.html">
<frame src="/example/html/frame_c.html">

<noframes>
<body>您的浏览器无法处理框架!</body>
</noframes>

</frameset>

</html>

混合框架结构, 本例演示如何制作含有三份文档的框架结构,同时将他们混合置于行和列之中。

<html>

<frameset rows="50%,50%">

<frame src="/example/html/frame_a.html">

<frameset cols="25%,75%">
<frame src="/example/html/frame_b.html">
<frame src="/example/html/frame_c.html">
</frameset>

</frameset>

</html>

含有 noresize=”noresize” 属性的框架结构, 本例演示 noresize 属性。在本例中,框架是不可调整尺寸的。在框架间的边框上拖动鼠标,你会发现边框是无法移动的。

<html>

<frameset cols="50%,*,25%">
<frame src="/example/html/frame_a.html" noresize="noresize" />
<frame src="/example/html/frame_b.html" />
<frame src="/example/html/frame_c.html" />
</frameset>

</html>

导航框架, 本例演示如何制作导航框架。导航框架包含一个将第二个框架作为目标的链接列表。名为 “contents.htm” 的文件包含三个链接.

<html>

<frameset cols="120,*">

<frame src="/example/html/html_contents.html">
<frame src="/example/html/frame_a.html" name="showframe">

</frameset>

</html>

内联框架, 本例演示如何创建内联框架(HTML 页中的框架)。

<html>

<body>

<iframe src="/i/eg_landscape.jpg"></iframe>

<p>一些老的浏览器不支持 iframe。</p>
<p>如果得不到支持,iframe 是不可见的。</p>


</body>
</html>

跳转至框架内的一个指定的节, 本例演示两个框架。其中的一个框架设置了指向另一个文件内指定的节的链接。这个”link.htm”文件内指定的节使用 <a name=”C10″> 进行标识。

<html>

<frameset cols="20%,80%">

<frame src="/example/html/frame_a.html">
<frame src="/example/html/link.html#C10">

</frameset>

</html>

使用框架导航跳转至指定的节, 本例演示两个框架。左侧的导航框架包含了一个链接列表,这些链接将第二个框架作为目标。第二个框架显示被链接的文档。导航框架其中的链接指向目标文件中指定的节。

<html>

<frameset cols="180,*">

<frame src="/example/html/content.html">
<frame src="/example/html/link.html" name="showframe">

</frameset>

</html>

发表评论

邮箱地址不会被公开。 必填项已用*标注

5 × 2 =