2011-10-29 2 views
1

무제한 스크롤로 작동하는 웹 페이지를 만들려고합니다. 이제 문제는 지금 작동하지 않는 것입니다 :페이지 하단으로 스크롤링 및 무제한 스크롤

window.scroll(function() { 
    alert('Scrolling'); 
    if ($(this)[0].scrollHeight - $(this).scrollTop() == $(this).outerHeight()) { 
      alert('Reached the bottom'); 
    } 
    }); 

가 나는 그것이 기본적으로 자바 스크립트에도 불구하고, JQuery와 정말 새로운 해요 (? 오른쪽) 어쨌든, 내가 무슨 일을하고 있는가? 나는 또한 document.scroll과 document.body.scroll을 시도했다.

답변

3

이 시도 : 시도

if ($(this).scrollTop() == $(document).height() - $(window).height()) { 
      alert('Reached the bottom'); 
    } 

내가 그것을 jsfiddle'd 그것은 작동합니다 http://jsfiddle.net/wcKVK/1/

1

적어도 하나의 오류가있다.

$(window).scroll(function() { 
    alert('Scrolling'); 
    if ($(this)[0].scrollHeight - $(this).scrollTop() == $(this).outerHeight()) { 
      alert('Reached the bottom'); 
    } 
    }); 
+0

이제는 스크롤하는 것을 인식하고 있습니다. 감사합니다. 이제 도달 한 문제를 해결하는 방법을 찾아야합니다. 나는 방금 '이것'을 넣었다는 것을 깨달았다. 어. 나는 아무것도하지 않았던 창문을 시험해 보았다. – Jake

1

을 나는 이것이 당신이 달성하려고하는 것입니다 생각 :

$(window).scroll(function() { 
    if ($('body').scrollTop() + $(window).height() == $('body').outerHeight()) { 
    alert('Reached the bottom'); 
    } 
}); 
+0

화면 상단에 도달했을 때이를 알려줍니다 ... –

-1
(function ($) { 
    $(window).scroll(function() { 
     if ($(this).scrollTop() == $(document).height() - $(window).height()) { 
      alert('bottom'); 
     } 
    }); 
}(jQuery)); 

은 저에게 효과적입니다.

+0

-1이 사람이 묻는 것 그대로입니다 ... 왜. –

관련 문제