You are here: Reference > JavaScript > client-side > HTML DOM > properties > contentType (document, XMLDocument)
contentType property (document, XMLDocument)
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.
Syntax:
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:
|
||||
<head> <script type="text/javascript"> function GetContentType () { if ('contentType' in document) { alert (document.contentType); } else { alert ("Your browser does not support the document.contentType property!"); } } </script> </head> <body> <button onclick="GetContentType ();">Get the MIME type of the current document!</button> </body> |
||||
|
||||
Did you find this example helpful?
|
Supported by objects:
Related pages:
External links:
User Contributed Comments