본문 바로가기
Programing Language/Javascript

[Javascript] 현재 화면 높이 구하기

by pcm9881 2023. 4. 3.

get document body height

 

1. 높이 요소 중 최대값 구하기

const body = document.body;
const html = document.documentElement;
const height = Math.max(
    body.scrollHeight,
    body.offsetHeight,
    html.clientHeight,
    html.scrollHeight,
    html.offsetHeight
);
console.log(height);

 

 

참조

[stakoverflow]: https://stackoverflow.com/questions/1145850/how-to-get-height-of-entire-document-with-javascript

 

How to get height of entire document with JavaScript?

Some documents I can't get the height of the document (to position something absolutely at the very bottom). Additionally, a padding-bottom on seems to do nothing on these pages, but do on the pages

stackoverflow.com

728x90

댓글