HTML - DOM 文件 documentMode 屬性



documentMode 屬性是 IE8 的一個屬性,它決定了瀏覽器使用的渲染模式。IE8 可以根據不同的因素(如 DOCTYPE 宣告和某些元素的存在)以各種模式渲染網頁。

根據使用的模式,documentMode 屬性將返回一個數值。documentMode 屬性已棄用,因為它僅在 Internet Explorer 中有效。

語法

document.documentMode;

返回值

在 Internet Explorer 中,它根據用於渲染網頁的模式返回一個數值。在所有其他瀏覽器中返回 undefined。

  • 對於 IE5,返回值為 5。
  • 對於 IE7,返回值為 7。
  • 對於 IE8,返回值為 8。

HTML DOM 文件“documentMode”屬性示例

在以下示例中,使用了 documentMode 屬性,它返回 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>

支援的瀏覽器

屬性 Chrome Edge Firefox Safari Opera
documentmode
html_dom_document_reference.htm
廣告