검색결과 리스트
scroll에 해당되는 글 1건
- 2014.06.16 [JavaScript] 현재 화면 스크롤 위치 알아내기
글
링크: http://www.howtocreate.co.uk/tutorials/javascript/browserwindow
function getSize() {
var myWidth = 0, myHeight = 0;
if( typeof( window.innerWidth ) == 'number' ) {
//Non-IE
myWidth = window.innerWidth;
myHeight = window.innerHeight;
} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
//IE 6+ in 'standards compliant mode'
myWidth = document.documentElement.clientWidth;
myHeight = document.documentElement.clientHeight;
} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
//IE 4 compatible
myWidth = document.body.clientWidth;
myHeight = document.body.clientHeight;
}
return [myWidth, myHeight];
}
function getScrollXY() {
var scrOfX = 0, scrOfY = 0;
if( typeof( window.pageYOffset ) == 'number' ) {
//Netscape compliant
scrOfY = window.pageYOffset;
scrOfX = window.pageXOffset;
} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
//DOM compliant
scrOfY = document.body.scrollTop;
scrOfX = document.body.scrollLeft;
} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
//IE6 standards compliant mode
scrOfY = document.documentElement.scrollTop;
scrOfX = document.documentElement.scrollLeft;
}
return [ scrOfX, scrOfY ];
}
'JavaScript > JavaScript' 카테고리의 다른 글
[JavaScript] JavaScript method overloading (0) | 2014.06.26 |
---|---|
[ScalaJs] Scala.js (0) | 2014.06.22 |
[JavaScript] RegExr (0) | 2014.06.14 |
[JavaScript] Array.prototype.shift(), Array.prototype.pop() (0) | 2014.05.20 |
[JavaScript] 자바스크립트 라이브러리 관리 bower (0) | 2014.05.18 |
RECENT COMMENT