You are here: Reference > JavaScript > client-side > HTML DOM > properties > contentType (document, XMLDocument)

contentType property (document, XMLDocument)

Browser support:
Sets or retrieves the MIME type of the current document.
This property returns the type of the contents specified in the HTTP entity-header, it is completely independent of the content-type specified in the head section with a meta element.
In Internet Explorer, the mimeType property provides similar functionality.


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

Possible values:

String that contains the MIME type.
Default: this property has no default value.

Example HTML code 1:

This example illustrates the use of the contentType property:
    <script type="text/javascript">
        function GetContentType () {
            if ('contentType' in document) {
                alert (document.contentType);
            } else {
                alert ("Your browser does not support the document.contentType property!");
    <button onclick="GetContentType ();">Get the MIME type of the current document!</button>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content