<frame>、<iframe>、<embed>、<object> 和 <applet>

frame

frame 必须在 frameset 里,而 frameset 又不能和 body 共存(就是一旦存在 frame,就不能存在 body 了,因此这个基本每人使用)

推荐阅读:https://www.w3school.com.cn/tags/tag_frame.asp

<html>

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

</html>

Iframe

我们最为熟知的就是 iframe 了,它很灵活,不需要放在 frameset 中,它可以放在 body 里面。

推荐阅读:https://www.w3school.com.cn/tags/tag_iframe.asp

<html>
<body>

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

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

</body>
</html>

embed

中文翻译,“嵌套”。常用于嵌入插件( 浏览器插件、flash插件)。

注意:大多数现代浏览器已经弃用并取消了对浏览器插件的支持。

推荐阅读:https://www.w3school.com.cn/tags/tag_embed.asp

<!DOCTYPE HTML>
<html>
<body>

<embed src="/i/helloworld.swf" />

</body>
</html>

object

HTML <object> 元素(或者称作 HTML 嵌入对象元素)表示引入一个外部资源,这个资源可能是一张图片,一个嵌入的浏览上下文,亦或是一个插件所使用的资源。

推荐阅读:https://developer.mozilla.org/zh-CN/docs/Web/HTML/Element/object

<!-- 嵌入一个 pdf -->
<object type="application/pdf"
    data="/media/examples/In-CC0.pdf"
    width="250"
    height="200">
</object>

<!-- 嵌入一个 flash 电影 -->
<object data="move.swf" type="application/x-shockwave-flash"></object>

<!-- 嵌入一个带参数的 flash 电影 -->
<object data="move.swf" type="application/x-shockwave-flash">
  <param name="foo" value="bar">
</object>

ps:object 和 embed 的使用,在国内视频厂商的嵌入视频方案,体现得淋漓尽致:https://harttle.land/2017/02/12/embeding-video-sites.html

applet

HTML中的Applet元素(<applet>) 标志着包含了Java的applet。

注意:这个元素已经被H5废弃,W3C规范不鼓励使用<applet>,更倾向于使用<object>标签。

推荐阅读:https://developer.mozilla.org/zh-CN/docs/Web/HTML/Element/applet

<applet code="game.class" align="left" archive="game.zip" height="250" width="350">
  <param name="difficulty" value="easy">
  <b>Sorry, you need Java to play this game.</b>
</applet>

猜你喜欢

转载自www.cnblogs.com/amiezhang/p/11456815.html
今日推荐