You are here: Reference > JavaScript > client-side > browser > objects > mimeTypes

mimeTypes collection

Browser support:
Represents a collection of all supported MIME types.
Internet Explorer supports the mimeTypes collection but it is always empty and there is no way to get the supported MIME types in this the browser.

Syntax:

Properties that reference the object:
object.mimeTypes
Related objects:
The base interface, through which you can add new functionalities to the mimeTypes collection, is the MimeTypeArray interface.

Possible members:

Properties:
length
Returns an integer that specifies the number of objects in the current collection.

This property is read-only.
Methods:
[nameOrIndex]
Returns an object from the current collection by name or index.

Parameters:

nameOrIndex
Required. A string that specifies the name or a zero-based integer that specifies the position of the mimeType object to retrieve.

Return value:

Returns an mimeType object.
item (index)
Returns an object from the current collection by index.

Parameters:

index
Required. Zero-based integer that specifies the position of the mimeType object to retrieve.

Return value:

Returns the mimeType object at the specified position.
namedItem (name)
Returns an object from the current collection by name.

Parameters:

name
Required. String that specifies the name of the mimeType object to retrieve.

Return value:

Returns the mimeType object with the specified name.

Example HTML code 1:

This example illustrates the use of the mimeTypes collection:
<head>
    <script type="text/javascript">
        function GetMimeTypes () {
            var message = "";
                // Internet Explorer supports the mimeTypes collection, but it is always empty
            if (navigator.mimeTypes && navigator.mimeTypes.length > 0) {
                var mimes = navigator.mimeTypes;
                for (var i=0; i < mimes.length; i++) {
                    message += "<b>" + mimes[i].type + "</b> : " + mimes[i].description + "<br />";
                }
            }
            else {
                message = "Your browser does not support this example!";
            }

            var info = document.getElementById ("info");
            info.innerHTML = message;
        }
    </script>
</head>
<body onload="GetMimeTypes ()">
    Supported MIME types:
    <div id="info" style="width:500px; height:300px; overflow:auto; background-color:#e0d0d0;"></div>
</body>
Did you find this example helpful? yes no

External links:

User Contributed Comments

Post Content

Post Content