Table of Contents | Previous
| Next
| Index
A MIME type (Multipart Internet Mail Extension) supported by the client.
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).
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:
This object inherits the watch and unwatch methods from Object.
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>", "<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>")
The preceding example displays output similar to the following:
navigator, navigator.mimeTypes, Plugin
A human-readable description of the data type described by the MIME type object.
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.
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.
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.") }
A string listing possible file suffixes (also known as filename extensions) for the MIME type.
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".
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".
MimeType
Table of Contents | Previous
| Next
| Index
Last Updated: 05/28/99 11:59:58
Copyright (c) 1999
Netscape Communications Corporation
|