Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. Navigator
  4. mimeTypes

Navigator: mimeTypes property

Returns aMimeTypeArray object, which contains a list ofMimeType objects representing the MIME types recognized and supported by the browser.The array can be queried for information about the enabled plugin that is used to handle a file of the specified type.Named properties of the returned object are not enumerable (except in very old browser versions).

Recent versions of the specification hard-code the returned set of MIME types.If PDF files can be displayed inline thenapplication/pdf andtext/pdf are listed.Otherwise an empty list is returned.

Note:UseNavigator.pdfViewerEnabled to determine if inline viewing of PDF files is supported. Do not infer it from this property.

Legacy browser versions do not hard-code the list returned by the property, and might return other MIME types.

Value

AMimeTypeArray object which has alength property as well asitem(index) andnamedItem(name) methods.

If PDF inline viewing is supported this has entries for MIME typesapplication/pdf andtext/pdf.Otherwise an emptyMimeTypeArray is returned.The description and file suffixes supported by enabled plugins are hard coded to'pdf' and'Portable Document Format', respectively.

Examples

The code below tests whether PDF files can be viewed inline, and then prints the description of the plugin and the file suffixes it supports.

js
if ("application/pdf" in navigator.mimeTypes) {  // browser supports inline viewing of PDF files.  const { description, suffixes } = navigator.mimeTypes["application/pdf"];  console.log(`Description: ${description}, Suffix: ${suffixes}`);  // expected output: Description: Portable Document Format, Suffix: pdf}

Note that while the above code tests forapplication/pdf you could equally well checktext/pdf. (Either both or neither MIME type will be true.)In addition, on current browsers you don't actually need to get the plugin description and suffixes, because this information is also hard-coded.

Specifications

Specification
HTML
# dom-navigator-mimetypes

Browser compatibility

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2026 Movatter.jp