Window innerHeight 屬性

定義和用法

innerHeight 屬性返回窗口內容區域的高度。

innerHeight 屬性是只讀的。

另請參閱:

innerWidth 屬性

outerWidth 屬性

outerHeight 屬性

實例

例子 1

獲取窗口高度:

let height = window.innerHeight;

親自試一試

let height = innerHeight;

親自試一試

例子 2

所有高度和寬度屬性:

let text =
"<p>innerWidth: " + window.innerWidth + "</p>" +
"<p>innerHeight: " + window.innerHeight + "</p>" +
"<p>outerWidth: " + window.outerWidth + "</p>" +
"<p>outerHeight: " + window.outerHeight + "</p>";

親自試一試

語法

window.innerHeight

或者:

innerHeight

返回值

類型 描述
數字 瀏覽器窗口內容區域的內部高度(以像素計)。

瀏覽器支持

所有瀏覽器都支持 window.innerHeight

Chrome IE Edge Firefox Safari Opera
Chrome IE Edge Firefox Safari Opera
支持 9-11 支持 支持 支持 支持