You are here: Reference > JavaScript > client-side > HTML DOM > properties > mimeType (document, a, img)

mimeType property (document, a, img)

Browser support:
Retrieves the type of the document file or the type of a linked file.
This type is different from the MIME type, it is the description that belongs to the file extension in the current operating system.
If you need the MIME type of the current document, use the contentType property although it is only supported by Firefox.

Syntax:

object.mimeType;
You can find the related objects in the Supported by objects section below.
This property is read-only.

Possible values:

String that represents the description of the file extension.
Default: this property has no default value.

Example HTML code 1:

This example illustrates the use of the mimeType property:
<head>
    <script type="text/javascript">
        function GetFileDescription () {
            var image = document.getElementById ("image");
            if ('mimeType' in image) {
                alert (image.mimeType);
            } else {
                alert ("Your browser doesn't support the mimeType property.");
            }
        }
    </script>
</head>
<body>
    <img id="image" src="picture.gif" />
    <button onclick="GetFileDescription ();">Get the description of the type of the image</button>
</body>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

User Contributed Comments

Post Content

Post Content