HTML - DOM Document documentMode Property



The documentMode property is an IE8 property which determines the rendering mode used by browser. IE8 can render a webpage in various modes depending on different factors like DOCTYPE declaration and presence of certain elements.

Depending on the mode being used, documentMode property would return a numeric value. The documentMode property is deprecated as it works only in Internet Explorer.

Syntax

document.documentMode;

Return Value

In Internet Explore, it returns a numeric value depending on which mode is being used to render the webpage. It returns undefined in all other browsers.

  • For IE5, value returned will be 5.
  • For IE7, value returned will be 7.
  • For IE8, value returned will be 8.

Example of HTML DOM Document 'documentMode' Property

In the following example, documentMode property is used which returns undefined.

<!DOCTYPE html>
<html lang="en">

<head>
    <title>
        HTML DOM Document documentMode Property
    </title>
</head>

<body>
    <p>Click below to get the documentMode</p>
    <button onclick="fun()">Click me</button>
    <p id="mode"></p>
    <script>
        function fun() {
            let x = document.documentMode;
            document.getElementById("mode").innerHTML = x;
        }
    </script>
</body>

</html>

Supported Browsers

Property Chrome Edge Firefox Safari Opera
documentmode No No No No No
html_dom.htm
Advertisements