框架
通过使用框架,你可以在同一个浏览器窗口中显示不止一个页面。
每份HTML文档称为一个框架,并且每个框架都独立于其他的框架。
使用框架的坏处:
1. 开发人员必须同时跟踪更多的HTML文档
2. 很难打印整张页面
框架结构标签(<frameset>
)
框架结构标签()定义如何将窗口分割为框架
每个 frameset 定义了一系列行或列
rows/columns 的值规定了每行或每列占据屏幕的面积
基本的注意事项 - 有用的提示:
假如一个框架有可见边框,用户可以拖动边框来改变它的大小。为了避免这种情况发生,可以在 <frame>
标签中加入:noresize=”noresize”。
为不支持框架的浏览器添加 <noframes>
标签。
重要提示:
不能将 <body></body>
标签与 <frameset></frameset>
标签同时使用!不过,假如你添加包含一段文本的 <noframes>
标签,就必须将这段文字嵌套于 <body></body>
标签内。
垂直框架
代码:
<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>
<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>
效果
含有 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>
效果
内联框架
iframe 用于在网页内显示网页。
Iframe - 删除边框
frameborder 属性规定是否显示 iframe 周围的边框。
设置属性值为 “0” 就可以移除边框:
代码
<html>
<body>
<iframe src="/i/eg_landscape.jpg"></iframe>
<p>一些老的浏览器不支持 iframe。</p>
<p>如果得不到支持,iframe 是不可见的。</p>
</body>
</html>
效果