JavaScript Tutorial/Document/MimeType

Материал из Web эксперт
Перейти к: навигация, поиск

MimeType

The MimeType object is a predefined JavaScript object that you access through the mimeTypes array of the Navigator or Plugin object.

MIME stands for Multipart Internet Mail Extension.

Property/Method Description description Returns description of MimeType enabledPlugin Returns plug-in for specific MimeType suffixes Returns file extension for MimeType type Returns string representation of MimeType



<html>
    <head>
    <title> Example of how to determine the available MimeTypes</title>
    </head>
    <body>
    <script language="JavaScript">
    <!--
    for (i=0; i < 3; i++) {
       document.writeln(navigator.mimeTypes[i].type+" ");
       document.writeln(navigator.mimeTypes[i].description+" ");
       document.writeln(navigator.mimeTypes[i].suffixes+" ");
       document.writln("<br>");
    }
    -->
    </script>
    </body>
    </html>


MimeType.description

The description property gets a description of the data type described by the MimeType object.



<html>
    <head>
    <title> Using the description property of the MimeType object</title>
    </head>
    <body>
    <script language="javascript">
    <!---
    for (i=0; i < 3; i++) {
       document.write("MimeType description " + i + " : ");
       document.writeln(navigator.mimeTypes[i].description);
       document.write("<br>");
    }
    -->
    </script>
    </body>
    </html>


MimeType.enabledPlugin

The enabledPlugin property determines which plug-in is configured for a specific MIME type.



<html>
    <head>
    <title> Using the enabledPlugin property of the MimeType object</title>
    </head>
    <body>
    <script language="javascript">
    <!---
    for (i=0; i < 3; i++) {
       document.write("MimeType enabledPlugin " + i + " : ");
       document.writeln(navigator.mimeTypes[i].enabledPlugin);
       document.write("<br>");
    }
    -->
    </script>
    </body>
    </html>


MimeType.suffixes

The suffixes property obtains a string listing the possible file suffixes or filename extensions for the MIME type.



<html>
    <head>
    <title> Using the suffixes property of the MimeType object</title>
    </head>
    <body>
    <script language="javascript">
    <!---
    for (i=0; i < 3; i++) {
       document.write("MimeType suffix " + i + " : ");
       document.writeln(navigator.mimeTypes[i].suffixes);
       document.write("<br>");
    }
    -->
    </script>
    </body>
    </html>


MimeType.type

The type property obtains a string specifying the name of the MIME type.



<html>
    <head>
    <title> Using the type property of the MimeType object</title>
    </head>
    <body>
    <script language="javascript">
    <!---
    for (i=0; i < 3; i++) {
       document.write("MimeType type " + i + " :");
       document.writeln(navigator.mimeTypes[i].type);
       document.write("<br>");
    }
    -->
    </script>
    </body>
    </html>