English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML Referenzhandbuch

Vollständiges Verzeichnis der HTML-Tags

HTML: <object> Tag

HTML: Der <object>-Tag wird als Container verwendet, um externe Ressourcen in ein HTML-Dokument einzubinden, z.B. Audio, Video, Flash, PDF, externe Anwendungen oder Browser-Plugins. Aufgrund der Kompatibilitätsprobleme wird der <object>-Tag häufiger verwendet als der <embed>-Tag, um Ressourcen einzubinden. Dieser Tag wird auch oft als <object>-Element bezeichnet.

Online-Beispiel

Verwenden Sie das <object>-Element, um Flash-Dateien in HTML einzufügen:

!DOCTYPE html>
<html>
<head> 
<meta charset="utf-8"> 
<title>Grundlagen-Tutorial-Website(oldtoolbag.com)</title> 
</head>
<body>
<object type="application/x-shockwave-flash" src="bookmark.swf" width="400" height="300"></object>
</body>
</html>
Testen Sie es heraus ‹/›

Browserkompatibilität

IEFirefoxOperaChromeSafari

目前大多数浏览器支持 <object> 标签。

标签定义及使用说明

定义一个嵌入的对象。请使用此元素向您的 XHTML 页面添加多媒体。此元素允许您规定插入 HTML 文档中的对象的数据和参数,以及可用来显示和操作数据的代码。

<object> 标签用于包含对象,比如图像、音频、视频、Java applets、ActiveX、PDF 以及 Flash。

object 的初衷是取代 img 和 applet 元素。不过由于漏洞以及缺乏浏览器支持,这一点并未实现。

浏览器的对象支持有赖于对象类型。不幸的是,主流浏览器都使用不同的代码来加载相同的对象类型。

而幸运的是,object 对象提供了解决方案。如果未显示 object 元素,就会执行位于 <object> 和 </> 之间的代码。通过这种方式,我们能够嵌套多个 object 元素(每个对应一个浏览器)。

与<embed>标签相比,<object>标签更常用于嵌入外部资源,因为<object>标签与HTML5,HTML 4.01和XHMTL兼容。

HTML 4.01 与 HTML5中的差异

一些 HTML 4.01 属性在 HTML5 中不被支持。

"form" 是 HTML5 定义的新属性。

在 HTML5 中,objects 可以在form表单中提交。

在 HTML5 中,objects 不再出现在 <head> 元素区域内。

属性

属性描述
aligntop bottom middle left rightHTML5 Not supported. HTML 4.01 Deprecated. 规定 <object> 元素相对于周围元素的对齐方式。
archiveURLHTML5 不支持。由空格分隔的指向档案文件的 URL 列表。这些档案文件包含了与对象相关的资源。
borderpixelsHTML5 Not supported. HTML 4.01 Deprecated. 规定 <object> 周围的边框宽度。
classidclass_IDHTML5 不支持。定义嵌入 Windows Registry 中或某个 URL 中的类的 ID 值,此属性可用来指定浏览器中包含的对象的位置,通常是一个 Java 类。
codebaseURLHTML5 不支持。定义在何处可找到对象所需的代码,提供一个基准 URL。
codetypeMIME_typeHTML5 不支持。通过 classid 属性所引用的代码的 MIME 类型。
dataURL定义对象使用的资源的 URL。
declaredeclareHTML5 Not supported. Defines that the object can only be declared, but cannot be created or instantiated until the object is applied.
formHTML5form_idSpecifies one or more forms to which the object belongs.
heightpixelsSpecifies the height of the object.
hspacepixelsHTML5 Not supported. HTML 4.01 Deprecated. Specifies the spacing to the left and right of the object.
namenameSpecifies a name for the object.
standbytextHTML5 Not supported. Defines the text to be displayed while the object is loading.
typeMIME_typeSpecifies the MIME type of the data specified in the data attribute.
usemap#mapnameSpecifies the name of the client-side image map to be used with the object.
vspacepixelsHTML5 Not supported. HTML 4.01 Deprecated. Specifies the spacing above and below the object.
widthpixelsSpecifies the width of the object.

Global Attributes

<object> Tag supports global attributes, see the complete attribute table HTML Global Attributes.

event attributes

<object> Tag supports all HTML Event Attributes.

Related Articles

HTML Tutorial:HTML Object Element