Main Page

MIME Types

?
ActiveX Objects
— ActiveX objects are everywhere in Internet Explorer. You can use them from
JavaScript and you can embed them in Web pages. Although not technically a plugin, because
ActiveX support exists in Internet Explorer itself, ActiveX objects are embedded into a Web page
the same way as other plugins.
?
Macromedia Shockwave
— Before there was Flash, there was Shockwave. Shockwave plays
files created in Macromedia Director, a multimedia programming environment allowing devel-
opers to create interactive demos, games, and other advanced content. Although not as popular
since Flash gained notoriety, Shockwave is still available on both Windows and MacOS.
MIME Types
When talking about plugins, the concept of MIME types is central. MIME stands for Multipurpose
Internet Mail Extension, a simple text string originally designed to determine the format of e-mail
attachments. From that humble beginning, MIME types (also called content types) have grown into the
de facto standard for identifying file formats on the Internet.
Each MIME type is made up of a media type and a subtype. The media type can be application, image,
audio, video, text, message, model, and multipart. The subtype is typically a more unique identifier,
specifying anything from the type of compression scheme used to the file extension. The media type
and subtype are separated by a forward-slash (/), such as
text/css
, which tells the browser (or other
Internet application) that the file is plain text and is also a CSS style sheet. Browser plugins work by
mapping themselves to specific MIME types, telling the browser that when this specific type of file has
to be handled, it should be done by the plugin.
Naturally, several MIME types are handled by the browser itself, such as
text/javascript
(JavaScript
files),
text/css
(CSS style sheets),
image/gif
(GIF-encoded images),
image/jpeg
(JPEG-encoded
images),
text/xml
(XML files), and
text/html
(HTML files). Many others, however, are handled by
plugins.
Embedding Plugins
To embed a plugin into a Web page, HTML offers the
<object/>
element. At the very least,
<object/>
requires four attributes:
?
type
— The MIME type of the file or object being embedded
?
data
— The URL of a file to load into the object
?
width
— The horizontal space the object should take up in the page
?
height
— The vertical space the object should take up in the page
The browser internally equates the MIME type of a file with a particular plugin, so setting the
type
attribute is enough to tell the browser which plugin to load. For example, the content type for a Flash file
is
application/x-shockwave-flash
, so the following code is all you need to embed a Flash movie:
<object type=”application/x-shockwave-flash” data=”myflashmovie.swf”
width=”100” height=”100”></object>
533
Interacting with Plugins
21_579088 ch18.qxd 3/28/05 11:43 AM Page 533


JavaScript EditorFree JavaScript Editor     Ajax Editor


©