켈

문서의 총 높이값 알아내는 자바스크립트

· 2011-11-14 (월) 17:47:59 · 3009 · 2
jQuery 안 쓴다면 아래 코드가 제일 심플한 듯...



문서의 총 높이값 : 이 페이지의 맨 아래로 갈 때 window.scroll(0,getDocHeight()); 로 활용
출처 : http://james.padolsey.com/javascript/get-document-height-cross-browser/
It’s been tested in IE6/7, FF2/3, Safari (Windows), Google Chrome and Opera 9.5.
 

function getDocHeight() {
var D = document;
return Math.max(
Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),
Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),
Math.max(D.body.clientHeight, D.documentElement.clientHeight)
);
}
|

댓글 2개

jquery쓴다면 $(window).height()
2011-11-30 (수) 12:05:31
으음, 필요할때 못찾다가 이렇게 여유가 있으니 찾아지는군요.
좋은 팁 감사합니다~
댓글을 작성하시려면 로그인이 필요합니다.

개발자팁

5,403건

개발과 관련된 유용한 정보를 공유하세요. 질문은 QA에서 해주시기 바랍니다.

+
분류 제목 글쓴이 날짜 조회
Mobile 11-12-19 조회 4,563
jQuery 11-12-17 조회 3,306
MySQL 11-12-17 조회 3,589
MySQL 11-12-17 조회 2,931
node.js 11-12-16 조회 2,537
node.js 11-12-15 조회 2,852
node.js
[node.js]
11-12-15 조회 2,986
node.js 11-12-15 조회 5,722
JavaScript 11-12-15 조회 3,103
Linux 11-12-14 조회 1,951
PHP 11-12-14 조회 4,205
jQuery 11-12-12 조회 2,697
Linux 11-12-12 조회 2,781
node.js 11-12-09 조회 3,087
Mobile 11-12-09 조회 3,577
Mobile 11-12-09 조회 2,927
Mobile 11-12-09 조회 3,369
Mobile 11-12-09 조회 4,480
node.js 11-12-09 조회 2,357
기타 11-12-09 조회 3,104
Flash 11-12-08 조회 2,728
PHP 11-12-08 조회 2,801
jQuery 11-12-08 조회 1.2만
PHP 11-12-08 조회 4,454
jQuery 11-12-08 조회 3,035
JavaScript 11-12-08 조회 3,049
node.js 11-12-07 조회 2,453
jQuery 11-12-07 조회 3,368
Flash 11-12-07 조회 3,820
node.js 11-12-07 조회 3,466