最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Scroll Down the page event - Stack Overflow

programmeradmin0浏览0评论

How can I catch the event of scroll down the page? I mean I want to have function call if the user scroll down to the end of the page?

Using Prototype JS or pure Javascript.

How can I catch the event of scroll down the page? I mean I want to have function call if the user scroll down to the end of the page?

Using Prototype JS or pure Javascript.

Share Improve this question edited Jul 20, 2019 at 18:56 Brian Tompsett - 汤莱恩 5,89372 gold badges61 silver badges133 bronze badges asked May 27, 2011 at 11:57 ehsun7behsun7b 4,86614 gold badges63 silver badges99 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 4

You would need to bind a scroll event to the window and then check the scroll position.

$(window).observe('scroll', function(event) {
    var scrollOffsets = document.viewport.getScrollOffsets();
    var scrollTop = scrollOffsets.top;
});

Using prototypejs try this,

$(document).observe('scroll', function(event) {     
  alert("the page has been scrolled"); 
  //call the user function
});

or try this,

Event.observe(window,'scroll', function(event) {        alert("the page has been scrolled");    
//call the user function 
}); 
发布评论

评论列表(0)

  1. 暂无评论