document height 구하기(cross browser)
브라우저 지원사항 - 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) );
};