HTML DOM document contentType Property

The contentType property in HTML DOM returns the MIME type in which the document is being rendered. This is a read only property.

Syntax:

value = document.contentType;

Return value: This property returns a string value of MIME content type of the document.

Example: This example will show how to get the content MIME Type of the document using this property.

HTML




<!DOCTYPE html>
<html>
  
<body>
    <h1>zambiatek</h1>
  
    <button onclick="get()">
        Get The Content Type
        of document
    </button>
  
    <script>
        function get() {
            alert(document.contentType);
        }
    </script>
</body>
  
</html>


Output:

    Before Click the Button:


    After Click the Button:

Supported Browsers:

  • Google Chrome
  • Edge
  • Firefox
  • Opera
  • Safari
  • Internet Explorer
Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, zambiatek Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Check Also
Close
Back to top button