HTML and CSS Reference
In-Depth Information
using <object> Tags
The <object> tag was introduced in an early version of HTML and standardized in HTML ver-
sion 4.0; Microsoft's Internet Explorer supported <object> but not <embed> .The <object> tag is
non-empty; that is, it has an opening and closing tag. Alternative content — which is rendered if the
browser cannot handle the plug-in file — is placed within the tag pair. For example, if you wanted
to play an audio file in WAV format, your code might look like this:
<object data=”mySound.wav” type=”audio/wav” width=”200” height=”100”>
Your browser does not support this file format.
</object>
When encountering this code, a browser looks for whatever plug-in is registered to handle the speci-
fied audio format and loads the file defined in the data attribute. If no such plug-in is found, the text
within the tag is displayed as the alternative content.
Interestingly enough, the alternative content is not restricted to text or imagery: the <object> tag
can actually contain other <object> tags. This technique allows multiple alternatives to be pre-
sented to the browser in the hopes that one will be viable. Assume that the web designer had the
same audio content in both WAV and MP3 formats. Here's how you would code for that combina-
tion with an <object> tag:
<object data=”mySound.wav” type=”audio/wav” width=”200” height=”100”>
<object data=”mySound.mp3” type=”audio/mp3” width=”200” height=”100”>
Your browser does not support this file format.
</object>
</object>
Note that the text alternative content is still included in
case the user's browser does not support either of the
offered formats. When rendered in a browser, a small
control bar is displayed, as shown in Figure 23-1.
The <object> tag often incorporates a series of
<param> tags to define the plug-in settings for the spe-
cific content to be rendered. Here's some example code
for a QuickTime ActiveX plug-in used with Internet
Explorer:
<object classid=”clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B” width=”160”
height=”144” codebase=” http://www.apple.com/qtactivex/qtplugin.cab”>
<param name=”src” value=”mySample.mov”>
<param name=”autoplay” value=”true”>
<param name=”controller” value=”false”>
</object>
FiGure 23-1
Some of these parameters — classid and codebase — are required with the stated values to identify
the needed resource as an ActiveX QuickTime plug-in. Others, such as autoplay and controller ,
are configurable features particular to the plug-in. For more information, see the article at the Apple
support site at http://support.apple.com/kb/TA26444 .
 
Search WWH ::




Custom Search