Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6945259
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:24:47+00:00 2026-05-27T13:24:47+00:00

I’m trying to do some pagination when user scrolls to the bottom of the

  • 0

I’m trying to do some pagination when user scrolls to the bottom of the page, more content loads. Is there a way to get to say almost to the bottom of the page? Like maybe 1/3 from the bottom of the page?

$(window).scroll(function(){
    if ($(window).scrollTop() == ($(document).height() - $(window).height())/3)
    {
        alert('test');
    }
    // ...

This doesn’t do anything

But if I delete that 3 in the code, alert pops when I get at the bottom (dead end, cant scroll anymore). But I want the alert to show when I’m almost to the bottom.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T13:24:48+00:00Added an answer on May 27, 2026 at 1:24 pm

    The problem is:

    • You check if it is exactly equal. This is going to be rare
    • You check if it is 1/3rd down the page, not 2/3rds

    Try this – http://jsfiddle.net/y7Am2/:

    $(window).scroll(function(){
        var mostOfTheWayDown = ($(document).height() - $(window).height()) * 2 / 3;
        if ($(window).scrollTop() >= mostOfTheWayDown)
        {
            alert('test');
        }
    });
    

    But I recommend you use a specific pixel value from the bottom rather than a fractional value from the top. Base it on the height of your footer (a simple hand-tweaked value, or calculated).

    Your content might not be constant height. If not, and you use a fractional value, you will scroll to what seems like an arbitrary part of the page and the loading will queue. This will make your website seem unpredictable, or possibly less responsive if users are used to it loading earlier on longer pages.

    So do something like this instead – http://jsfiddle.net/PwZ4D/:

    $(window).scroll(function(){
        var mostOfTheWayDown = ($(document).height() - $(window).height())
            - 150 - footerHeight;
        // ...
    

    Also note that as currently implemented your event will keep firing every time you scroll around at the bottom of the page. This will queue up a whole ton of AJAX calls. You probably should unbind scroll inside your event, then rebind it when your ajax call finishes successfully.

    And be careful to handle cases where you have little to no content. If a page is empty or there is only enough data to fill one screen, it could keep re-querying the server needlessly if you do things wrong.

    Edit:

    Per request, you unbind the scroll event with code like this – http://jsfiddle.net/5vXJ5/:

    $(window).unbind('scroll');
    

    Edit:

    Again per request, you rebind it the same way you bound it to begin with. However, since you end up with self-referential code you’ll need to name your function. The final code might look something like this:

    var scrollHandler;
    scrollHandler = function(){
      var mostOfTheWayDown = ($(document).height() - $(window).height()) * 2 / 3;
    
      if ($(window).scrollTop() >= mostOfTheWayDown)
      {
        // So we don't queue up multiple requests until the first one completes
        $(window).unbind('scroll');
    
        $.ajax({
          url: "test.html",
          context: document.body,
          success: function(){
            $(window).scroll(scrollHandler); // re-bind after it completes
          }
        });
      }
    };
    
    $(window).scroll(scrollHandler); // bind by named function
    

    This is just an example though. You’ll have to tweak it to your specific scenario.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am trying to render a haml file in a javascript response like so:
In my XML file chapters tag has more chapter tag.i need to display chapters
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.