Home >Web Front-end >HTML Tutorial >Detailed explanation of Object tag and EMBED tag in html

Detailed explanation of Object tag and EMBED tag in html

黄舟
黄舟Original
2017-06-30 11:12:221722browse

In order to play Flash videos in the browser, the HTML document must contain the and tags and parameter settings. The OBJECT tag has 4 settings (HEIGHT, WIDTH, CLASSID and CODEBASE). They are all its attributes. Interested friends can learn about this articleDefinition and usage

Define an embedded object. Please use this element to add multimedia to your XHTML pages. This element allows you to specify data and parameters for objects inserted into an HTML document, as well as code that can be used to display and manipulate the data.

273238ce9338fbb04bee6997e5552b95 tag is used to contain objects such as images, audio, video, Java applets, ActiveX, PDF, and Flash.

Object was originally intended to replace img and applet elements. However, this did not happen due to bugs and lack of browser support.

The browser's object support depends on the object type. Unfortunately, major browsers all use different code to load the same object types.

Fortunately, the object object provides a solution. If the object element is not shown, the code between 273238ce9338fbb04bee6997e5552b95 and eb50c9ec568c9b96871b9e94a1ff3fd1 is executed. This way we can nest multiple object elements (one for each browser).

Use object (OBJECT) and embedded (EMBED) tags
In order to play Flash movies in the browser, the HTML document must contain the and tags, and set the parameters. For the EMBED tag, the settings enclosed in parentheses (such as HEIGHT, WIDTH, QUALITY and LOOP, etc.) are its attributes. For example:

<EMBED SRC="moviename.swf" WIDTH="100" HEIGHT="100" PLAY="true" LOOP="true" QUALITY="high" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/ index.cgi?P1_Prod_Version=ShockwaveFlash"> 
</EMBED>

OBJECT tag has 4 settings ( HEIGHT, WIDTH, CLASSID and CODEBASE), are all its properties. Other settings appear independently in the HTML document and are called parameter tags. For example:

<OBJECT CLASSID="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" WIDTH="100" HEIGHT="100"CODEBASE="http://active.macromedia.com/flash4/cabs/ swflash.cab#version=4,0,0,0"> 
<PARAM NAME="MOVIE" VALUE="moviename.swf"> 
<PARAM NAME="PLAY" VALUE="true"> 
<PARAM NAME="LOOP" VALUE="true"> 
<PARAM NAME="QUALITY" VALUE="high"> 
</OBJECT>

SRC
取值:影片名称(如movieName.swf)。
对应的模版变量:$MO
功能描述:指定要载入影片的名称,仅适用于“EMBED”标志中。

MOVIE
取值:影片名称(如movieName.swf)。
对应的模版变量:$MO
功能描述:指定要载入影片的名称,仅适用于“OBJECT”标志中。

CLASSID
取值:clsid:D27CDB6E-AE6D-11cf-96B8-444553540000
功能描述:指明浏览器所用的ActiveX控件,必须完全与上面的值相同,仅适用于“OBJECT”标志中。

WIDTH
取值:数字或百分数。
对应的模版变量:$WI.
功能描述:以像素数或浏览器窗口宽度的百分数形式指定影片的宽度。

HEIGHT
取值:数字或百分数。
对应的模版变量:$HE
功能描述:以像素数或浏览器窗口高度的百分数形式指定影片的高度。

因为Flash影片是可缩放的,所以在保持长宽比的前提下改变影片幅面的大小不会使影片的显示质量降低。

CODEBASE
取值:http://active.macromedia.com/flash4/cabs/swflash.cab
#version=4,0,0,0"

功能描述:指明Flash播放器的ActiveX控件的位置,当浏览器未安装它时,可自动到该位置下载。所赋的值必须完全与上面的值相同。仅适用于“OBJECT”标志中。

PLUGINSPAGE
P1_Prod_Version=ShockwaveFlash
功能描述:指明Flash播放器插件的位置,在需要时便于安装。所赋的值必须完全与上面的值相同。仅适用于“EMBED”标志中。

SWLIVECONNECT(可选)
取值:true或false.
功能描述:用于确定在第一次载入Flash播放器时是否启动Java,当该项被省略时取默认值False。无论什么时候只要在同一页面中包含JavaScript程序和Flash,为使“FS Commands”语句起作用,必须运行Java,但如果页面中的JavaScript程序仅用来实现监测浏览器的类型或其他与“FS Commands”语句无关的功能,则可以把SWLIVECONNECT置为false以阻止Java的启动,要启动Java,可显式地将SWLIVECONNECT 置为true,这将大大增加影片开始播放过程所用的时间。仅适用于“EMBED”标志中。

PLAY(可选)
取值:true或false.
对应的模版变量:$PL.
功能描述:用于指定当影片下载到浏览器之后是否立即播放。如果影片中包含交互元素,也许需要被演示者的相关操作来启动播放,这时可将该属性置为false来阻止影片的自动播放,该属性被省略时将按默认值true执行。

LOOP(可选)
取值:true或false。
对应的模版变量:$LO.
功能描述:指定影片是重复播放还是播放一遍后停止。该属性被省略时将按默认值true执行。

QUALITY(可选)
取值:low、high、autolow、autohig或best。
对应的模版变量:$QU.
功能描述:见前述。

该属性被省略时将按默认值high执行。

BGCOLOR(可选)
取值:#RRGGBB(16进制的RGB值)。
对应的模版变量:$BG
指定影片的背景色,该属性可取代Flash影片文件中背景色的设定,但不影响影片所在HTML页的背景色设定。

SCALE(可选)
取值:showall、noborder、exactfit.
对应的模版变量:$SC.
功能描述:当宽度和高度值以百分数表示时,确定影片被如何放置在浏览器窗口中。选项有以下几个:

“Show all” (默认值)在指定尺寸的区域中显示整个影片的内容并保持与原影片相同的长宽比例,影片内容不发生变形。
“No Border”在维持影片长宽比例的情况下填充指定区域,影片内容不发生变形,但影片的部分内容可能显示不出来。
“Exact Fit”使整个影片在指定区域可见,因为此时不再维持原有的长宽比例,所以影片有可能变形。

该属性被省略(且宽度和高度值以百分数表示时)时将按默认值showall 执行。

ALIGN
取值:L、R 、T、B.
对应的模版变量:$HA.
功能描述:设置“OBJECT”、“EMBED”和“IMG”标签中的“ALIGN”属性,决定影片在浏览器窗口中的位置。

省略时使影片置于浏览器窗口的中央,如果浏览器窗口尺寸比影片所占区域尺寸小,将调整浏览器窗口尺寸,使影片正常显示。

The "L" value aligns the video to the left side of the browser window. If the browser window is not large enough to accommodate the video, the top, bottom, and right edges of the window will be adjusted.
The "R" value aligns the video with the right side of the browser window. If the browser window is not large enough to accommodate the video, the top, bottom, and left edges of the window will be adjusted.
The "T" value aligns the video with the top edge of the browser window. If the browser window is not large enough to accommodate the video, the left, right, and bottom edges of the window will be adjusted.
The "B" value aligns the video with the bottom edge of the browser window. If the browser window is not large enough to accommodate the video, the left, right, and top edges of the window will be adjusted.

SALIGN (optional)
Values: L, R, T, B, TL, TR, BL, BR.
Corresponding template variables: $SA
Function description: Used to determine how the scaled video is placed in an area with specified width and height. The meaning of various values ​​can be found in the previous item.

BASE (optional)
Value: base path or URL.
Function Description: Used to specify the reference position of the relative path used in the video.

MENU (optional)
Values: true, false.
Corresponding template variable: $ME.
Function description: Used to specify in the browser The type of shortcut menu that appears when you right-click (Windows) or command-click (Macintosh) an area of ​​a movie.
A "True" value will display the entire menu, allowing the presentee to have a variety of controls over the screening process.
A value of "False" will display a menu containing only the "About Flash" menu item.

When this attribute is omitted, the default value "true" will be used.

WMODE (optional)
Values: Window, Opaque, Transparent.
Corresponding template variable: $WM.
Function description: This parameter is only available in Applicable to Windows systems with Flash Active X space.

The "Window" value causes the video to be played at the specified location on the web page. This is also the fastest playback speed among several options.
The "Opaque Windowless" value will block content behind the video on the web page.
The "Transparent" value causes the transparent portion of the video on the web page to display the content and background of the web page, potentially slowing down the animation.

When this attribute is omitted, the default value "Window" will be used and can only be used in Object tags.

1. Introduction:

If we want to display flash content normally in a web page, there must be a tag specifying the flash path in the page. That is, the OBJECT and EMBED tags. The OBJECT tag is used for IE browser on the windows platform, while EMBED is used for the Netscape Navigator browser under the windows and Macintosh platforms and the IE browser under the Macintosh platform. IE on the windows platform uses Activex controls to play flash, while other browsers use Netscape plug-in technology to play flash.

The following is a simple code example for inserting flash into a web page:

<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" 
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" 
WIDTH="550" HEIGHT="400" id="myMovieName"> 
<PARAM NAME=movie VALUE="myFlashMovie.swf"> 
<PARAM NAME=quality VALUE=high> 
<PARAM NAME=bgcolor VALUE=#FFFFFF> 
<EMBED src="http://www.doflash.net/"/support/flash/ts/documents/myFlashMovie.swf"" quality=high bgcolor=#FFFFFF WIDTH="550" HEIGHT="400" 
NAME="myMovieName" ALIGN="" TYPE="application/x-shockwave-flash" 
PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"> 
</EMBED> 
</OBJECT>


二、为什么要使用以上全部的标签?能省略某些标签不?

OBJECT标签是用于windows IE3.0及以后浏览器或者其它支持Activex控件的浏览器。“classid”和“codebase”属性必须要精确地按上例所示的写法写,它们告诉浏览器自动下载flash player的地址。如果你没有安装过flash player 那么IE3.0以后的浏览器会跳出一个提示框访问是否要自动安装flash player。当然,如果你不想让那些没有安装flash player的用户自动下载播放器,或许你可以省略掉这些代码。

EMBED标签是用于Netscape Navigator2.0及以后的浏览器或其它支持Netscape插件的浏览器。“pluginspage”属性告诉浏览器下载flash player的地址,如果还没有安装flash player的话,用户安装完后需要重启浏览器才能正常使用。

为了确保大多数浏览器能正常显示flash,你需要把EMBED标签嵌套放在OBJECT标签内,就如上面代码例子一样。支持Activex控件的浏览器将会忽略OBJECT标签内的EMBED标签。Netscape和使用插件的IE浏览器将只读取EMBED标签而不会识别OBJECT标签。也就是说,如果你省略了EMBED标签,那firefox就不能识别你的flash了(不过纳闷的是,省略了object只写embed,IE也能正常显示flash,呵呵,具体的再仔细看看了)。

下面列出了用于发布影片的OBJECT和EMBED标签的必要以及可选属性。

一、必需属性:

·CLASSID-设置浏览器的Activex控件,仅用于OBJECT标签。

·CODEBASE-设置flash Activex控件的位置,因而如果浏览器如果没有安装的话,可以自动下载安装。仅用于OBJECT标签。

·WIDTH-以百分比或象素指定flash影片的宽度。

·HEIGHT-以百分比或象素指定flash影片的高度。

·SRC-指定影片的下载地址。仅用于EMBED标签。

·PLUGINSPAGE-设置flash 插件的位置,因而如果浏览器如果没有安装的话,可以自动下载安装。仅用于EMBED标签。

·MOVIE-指定影片的下载地址。仅用于OBJECT标签。

二、可选属性及可用的值:

·ID-设定变量名,用于脚本代码的引用。仅用于OBJECT。

·NAME -设定变量名,用于脚本代码(如javascript)的引用。仅用于EMBED。

·SWLIVECONNECT - (true或false)指定当flash player第一次下载时,是否启用java。如果些属性省略,默认值为false。你果你在相同页同使用javascript和flash,java必须使用FSCommand来工作。

·PLAY -(true或false)指定flash影片是否在下载完成后就自动播放,如果省略此属性,则默认为true。

·LOOP - (true或false)指定影片播放完最后一帧后是停止还是继续循环播放,如果省略此属性,则默认为true。

·MENU - (true或false)

·True 显示全部的菜单,允许用户放大,缩小等控制影片播放等操作。

·False 显示只包含设置选项和关于flash的菜单。

·QUALITY - (low, high, autolow, autohigh, best )

·Low 速度优于美观,而且不应用反锯齿。

·Autolow 刚开始着重于速度,但当需要时随时提升美观。

·Autohigh 同时着重播放速度和美观,但需要时则牺牲美观来保证播放速度。

·Medium 应用一些反锯齿而不平滑位图。它质量高于low设置而低于high设置。

·High 美观优于播放速度,而且一直应用反锯齿。如果影片不包含动画,位图会被平滑化;而如果影片包含动画,位图将不变平滑。

·Best 提供最好的显示质量而不考虑播放速度。所有输出都应用反锯齿及所有位图都被平滑化。

·SCALE - (showall, noborder, exactfit)

·Default(Show all)影片在指定的区域内显示,但保持原始的比例。影片两侧将会出现边框。

·No Boder 收缩影片以适合指定的区域,保持影片不失真,但部分影片将可能将裁切。然而保持影片的原始比例。

·Exact Fit 使整个影片在指定的区域内显示,影片有可能变形失真,而且不保持原始的比例。

·ALIGN - (l, t, r, b)

·默认为居中,当浏览器窗口小于影片时,边缘会被裁切。

·Left,Right,Top,Bottom按照相应的设置沿浏览器的边缘对齐。如果需要,另外三边将被裁切。

·SALIGN - (l, t, r, b, tl, tr, bl, br)

·L,R,T,B

·TL,TR

·BL,BR

·WMODE- (window, opaque, transparent) Set the window mode attribute of the flash movie and specify the transparency, cascading and position of the flash in the browser.

·Window The video plays in its own rectangular window in the browser.

·Opaque film hides everything behind it.

·Transparent makes the flash video transparent and displays the web content behind the transparent video. This will reduce animation performance. And this property is not available in all browsers.

·BGCOLOR - (#RRGGBB, hexadecimal RGB value.) Specifies the background color of the video. Use this attribute to override the background color set in flash.

·BASE - Set the base directory or URL to resolve all relative paths in flash. Similar to the dde6fb694e6711ae5e6f381704c04ae4 tag in web pages.

·FLASHVARS transfers variables to flash player, which requires flash player 6 and later versions.

·Pass root-level variables to the video. The format of the string is a name=value set separated by "&".

·The browser supports a string length of 64kB.

The above is the detailed content of Detailed explanation of Object tag and EMBED tag in html. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn