[Contents] [Previous] [Next] [Index]

MimeType

A MIME type (Multipart Internet Mail Extension) supported by the client.

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:

Expression Value
navigator.mimeTypes["image/jpeg"].type

image/jpeg

navigator.mimeTypes["image/jpeg"].description

JPEG Image

navigator.mimeTypes["image/jpeg"].suffixes

jpeg, jpg, jpe, jfif, pjpeg, pjp

navigator.mimeTypes["image/jpeg"].enabledPlugins

null

Property Summary

description
A description of the MIME type.

enabledPlugin
Reference to the Plugin object configured for the MIME type.

suffixes
A string listing possible filename extensions for the MIME type, for example "mpeg, mpg, mpe, mpv, vbs, mpegv".

type
The name of the MIME type, for example "video/mpeg" or "audio/x-wav".

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>",
   "<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:

i type description suffixes enabledPlugin.name
0

audio/aiff

AIFF

aif, aiff

LiveAudio

1

audio/wav

WAV

wav

LiveAudio

2

audio/x-midi

MIDI

mid, midi

LiveAudio

3

audio/midi

MIDI

mid, midi

LiveAudio

4

video/msvideo

Video for Windows

avi

NPAVI32 Dynamic Link Library

5

*

Netscape Default Plugin

Netscape Default Plugin

6

zz-application/zz-winassoc-TGZ

TGZ

None

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

Property of

MimeType


[Contents] [Previous] [Next] [Index]

Last Updated: 10/31/97 12:32:33


Copyright © 1997 Netscape Communications Corporation