스크롤 막대가 페이지의 끝에 도달했는지 판단하기

5174 단어 스크롤 바

  
    
//
function getScrollTop()
{
var scrollTop = 0 ;
if (document.documentElement && document.documentElement.scrollTop)
{
scrollTop
= document.documentElement.scrollTop;
}
else if (document.body)
{
scrollTop
= document.body.scrollTop;
}
return scrollTop;
}


//
function getClientHeight()
{
var clientHeight = 0 ;
if (document.body.clientHeight && document.documentElement.clientHeight)
{
var clientHeight = (document.body.clientHeight < document.documentElement.clientHeight) ? document.body.clientHeight:document.documentElement.clientHeight;
}
else
{
var clientHeight = (document.body.clientHeight > document.documentElement.clientHeight) ? document.body.clientHeight:document.documentElement.clientHeight;
}
return clientHeight;
}


//
function getScrollHeight()
{
return Math.max(document.body.scrollHeight,document.documentElement.scrollHeight);
}
function test(){
if (getScrollTop() + getClientHeight() == getScrollHeight()){
alert(
" " );
}
else {
alert(
" " );
}
}

좋은 웹페이지 즐겨찾기