trycode
document height (cross browser) 본문
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 |