Client-side object | |
Implemented in | Navigator 3.0 |
Created by
You do not create MimeType
objects yourself. These objects are predefined JavaScript objects that you access through the mimeTypes
array of the navigator
or Plugin
object:
navigator.mimeTypes[index]
where index
is either an integer representing a MIME type supported by the client or a string containing the type of a MimeType
object (from the MimeType.type
property).
Description
Each MimeType
object is an element in a mimeTypes
array. The mimeTypes
array is a property of both navigator
and Plugin
objects. For example, the following table summarizes the values for displaying JPEG images:
Methods
None.
Examples
The following code displays the type
, description
, suffixes
, and enabledPlugin
properties for each MimeType
object on a client:
document.writeln("<TABLE BORDER=1><TR VALIGN=TOP>",
The preceding example displays output similar to the following:
"<TH ALIGN=left>i",
"<TH ALIGN=left>type",
"<TH ALIGN=left>description",
"<TH ALIGN=left>suffixes",
"<TH ALIGN=left>enabledPlugin.name</TR>")
for (i=0; i < navigator.mimeTypes.length; i++) {
document.writeln("<TR VALIGN=TOP><TD>",i,
"<TD>",navigator.mimeTypes[i].type,
"<TD>",navigator.mimeTypes[i].description,
"<TD>",navigator.mimeTypes[i].suffixes)
if (navigator.mimeTypes[i].enabledPlugin==null) {
document.writeln(
"<TD>None",
"</TR>")
} else {
document.writeln(
"<TD>",navigator.mimeTypes[i].enabledPlugin.name,
"</TR>")
}
}
document.writeln("</TABLE>")
See also
navigator
, navigator.mimeTypes
, Plugin
Properties
description
A human-readable description of the data type described by the MIME type object.
Property of |
MimeType
|
Read-only | |
Implemented in | Navigator 3.0 |
enabledPlugin
The Plugin
object for the plug-in that is configured for the specified MIME type If the MIME type does not have a plug-in configured, enabledPlugin
is null.
Property of |
MimeType
|
Read-only | |
Implemented in | Navigator 3.0 |
Description
Use the enabledPlugin
property to determine which plug-in is configured for a specific MIME type. Each plug-in may support multiple MIME types, and each MIME type could potentially be supported by multiple plug-ins. However, only one plug-in can be configured for a MIME type. (On Macintosh and Unix, the user can configure the handler for each MIME type; on Windows, the handler is determined at browser start-up time.)
The enabledPlugin
property is a reference to a Plugin
object that represents the plug-in that is configured for the specified MIME type.
You might need to know which plug-in is configured for a MIME type, for example, to dynamically emit an EMBED
tag on the page if the user has a plug-in configured for the MIME type.
Examples
The following example determines whether the Shockwave plug-in is installed. If it is, a movie is displayed.
// Can we display Shockwave movies?
mimetype = navigator.mimeTypes["application/x-director"]
if (mimetype) {
// Yes, so can we display with a plug-in?
plugin = mimetype.enabledPlugin
if (plugin)
// Yes, so show the data in-line
document.writeln("Here\'s a movie: <EMBED SRC=mymovie.dir HEIGHT=100 WIDTH=100>")
else
// No, so provide a link to the data
document.writeln("<A HREF='mymovie.dir'>Click here</A> to see a movie.")
} else {
// No, so tell them so
document.writeln("Sorry, can't show you this cool movie.")
}suffixes
A string listing possible file suffixes (also known as filename extensions) for the MIME type.
Property of |
MimeType
|
Read-only | |
Implemented in | Navigator 3.0 |
Description
The suffixes
property is a string consisting of each valid suffix (typically three letters long) separated by commas. For example, the suffixes for the "audio/x-midi"
MIME type are "mid, midi"
.
type
A string specifying the name of the MIME type. This string distinguishes the MIME type from all others; for example "video/mpeg"
or "audio/x-wav"
.
Property of |
MimeType
|
Read-only | |
Implemented in | Navigator 3.0 |
Last Updated: 10/31/97 12:32:33