반응형
Notice
Recent Posts
Recent Comments
Link
«   2025/05   »
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
Archives
Today
Total
관리 메뉴

trycode

document height (cross browser) 본문

javascript

document height (cross browser)

hello-world 2021. 1. 19. 22:54
728x90
반응형

document height 

브라우저 지원사항 - IE6/7, FF2/3, Safari (Windows), Google Chrome and Opera 9.5. 

 

아래에서 getDocHeight() 함수는 dom에서 content 요소 모두 포함된 height사이즈를 뜻한다.

현재 브라우저에서 보이는 window.height 와 아래의 height값은 서로 틀리니 참고.. 

 

 

function getDocHeight() {

    var doc= document;

    return Math.max(

        doc.body.scrollHeight, doc.documentElement.scrollHeight,

        doc.body.offsetHeight, doc.documentElement.offsetHeight,

        doc.body.clientHeight, doc.documentElement.clientHeight

    );

}

 

 

jQuery 사용시

 

$.getDocHeight = function(){

     var doc = document;

     return Math.max( Math.max(doc.body.scrollHeight, doc.documentElement.scrollHeight), 

                         Math.max(doc.body.offsetHeight, doc.documentElement.offsetHeight), 

                         Math.max(doc.body.clientHeight, doc.documentElement.clientHeight)   );

};

반응형

'javascript' 카테고리의 다른 글

Template literal(템플릿 리터럴)  (0) 2021.01.19
import 구문 - javascript  (0) 2021.01.19
ES6 Arrow Function  (0) 2021.01.19
TweenMax js버전  (0) 2021.01.19
regex (정규표현식) 연습  (0) 2021.01.19
Comments