object
元素實現(xiàn)與 embed
元素相同的結(jié)果。
它具有局部屬性:data,type,height,width,usemap,name,form
。
object
元素也可以有零個或多個參數(shù)元素。
表單屬性是HTML5中的新屬性。
archive,classid,code,codebase,codetype,declare,standby,align,hspace,vspace和border屬性都已過時。
以下代碼顯示了如何使用對象元素嵌入相同的YouTube視頻。
<!DOCTYPE HTML>
<html>
<body>
<object width="560" height="349"
data="http://www.youtube.com/v/qzA60hHca9s"
type="application/x-shockwave-flash">
<param name="allowFullScreen" value="true" />
</object>
</body>
</html>
data屬性提供了內(nèi)容的位置。 type,width和height屬性的含義與embed元素的含義相同。
您可以使用 param
元素定義要傳遞給插件的參數(shù)。
您需要為每個需要定義的參數(shù)使用一個 param
元素。
param
元素使用屬性名稱和值來定義參數(shù)。
使用對象元素,您可以包括如果您指定的內(nèi)容不可用將顯示的內(nèi)容。
<!DOCTYPE HTML>
<html>
<body>
<object width="560" height="349" data="http://www.15014759268.cn/myimaginaryfile">
<param name="allowFullScreen" value="true" />
<b>Sorry!</b> We can"t display this content
</object>
</body>
</html>
上面的代碼使用 data
屬性來引用不存在的文件。
瀏覽器將顯示 object
元素內(nèi)的內(nèi)容。將忽略 param
元素。
您可以使用 object
元素來嵌入圖像。
<!DOCTYPE HTML>
<html>
<body>
<object data="http://www.www.15014759268.cn/style/download.png" type="image/png"> </object>
</body>
</html>
您可以使用 object
元素創(chuàng)建客戶端圖像映射。 usemap
屬性可用于將map
元素與 objext
元素相關(guān)聯(lián)。
<!DOCTYPE HTML>
<html>
<body>
<map name="mymap">
<area href="a.html" shape="rect" coords="3,5,68,62"
alt="A" />
<area href="b.html" shape="rect" coords="70,5,130,62" alt="B" />
<area href="c.html" shape="default" alt="default" />
</map>
<object data="http://www.www.15014759268.cn/style/download.png" type="image/png" usemap="#mymap">
</object>
</body>
</html>
在撰寫本文時,Google Chrome和Apple Safari不支持此功能。
object和embed元素都通過添加對瀏覽器不直接支持的插件的支持來擴展瀏覽器的功能。
embed
元素具有局部屬性: src,type,height,width
。
以下代碼顯示了正在使用的embed元素。
<!DOCTYPE HTML>
<html>
<body>
<embed src="http://www.youtube.com/v/qzA60hHca9s" rel="external nofollow"
type="application/x-shockwave-flash"
width="560"
height="349"
allowfullscreen="true" />
</body>
</html>
src屬性指定內(nèi)容的位置。
type屬性指定內(nèi)容的MIME類型。
width和height屬性確定嵌入內(nèi)容的大小。
任何其他屬性都是插件或內(nèi)容的參數(shù)。
allowfullscreen
允許YouTube視頻播放器以全屏模式播放視頻。
更多建議: