25.19. The MimeType Object

The MimeType object describes a MIME type. The navigator.mimeTypes array lists all types supported by the browser, either directly by plug-ins or through external “helper” applications. For example, you could use code like the following to insert a link to an Adobe Acrobat file only if the current browser supports Acrobat; otherwise, you would use a plain text document.

document.writeln('For more information, see');
if (navigator.mimeTypes["application/pdf"] != null) {
  document.writeln
    ('<A HREF="manual.pdf">the widget manual</A>.');
} else {
  document.writeln
    ('<A HREF="manual.text">the widget manual</A>.');
}

For a list of common MIME types, see Table 19.1.

Properties

description This read-only property gives a textual ...

Get Core Web Programming, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.