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 9022785
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:36:16+00:00 2026-06-16T05:36:16+00:00

I am interested in determining when a user has reached the bottom of the

  • 0

I am interested in determining when a user has reached the bottom of the page in order to fire off a custom callback event, similar to “infinite scrolling” or “endless scrolling.”

My best theory on how to go about this is to first calculate the height of the body element:

var bodyHeight = $('body').outerHeight();

Next, measure the height of the window frame:

var winHeight = $(window).height();

and lastly determine the vertical scroll position:

var scrollY = $(window).scrollTop();

However, when I insert this script into the body:

<script>
console.log(bodyHeight, winHeight);
$(window).bind("scroll", function(){
console.log(winHeight + scrollY);
});
</script>

I will often see that the calculated scroll position exceeds the height of the body. I have seen something similar when using OSX with the “elastic scrolling” but this is only using the standard scrollbar ui.

Any thoughts?

  • 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-06-16T05:36:17+00:00Added an answer on June 16, 2026 at 5:36 am

    I think if you just stick with $(‘body’).height(), you should be fine.

    $('body').height() - $(window).height() == $('body').scrollTop()
    

    It is possible that you see the scrollTop() is off if you have position:absolute, position:fixed or floated elements. In this case, your body element doesn’t actually wrap the tallest element, so it doesn’t work.

    If that is the case, you can actually use scrollHeight.

    document.body.scrollHeight - $(window).height() == $('body').scrollTop()
    

    It looks like jQuery doesn’t have a scrollHeight method (or equivalent) and there are a few browser compatibility issues with it (W3C Dom Compatibility for scrollHeight), but it works in all modern browsers.

    Worst case scenario, you could get all elements, loop through them to find the max height and then use that for:

    var maxHeight = ((function() { var maxHeight = 0; $('*').each(function() {
        maxHeight = Math.max($(this).height(), maxHeight);
    }); return maxHeight; })());
    
    maxHeight - $(window).height() == $('body').scrollTop()
    

    If you use that approach, I HIGHLY recommend you cache the value and update it only as needed.

    JSFiddle

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

Sidebar

Related Questions

I'm writing a program which has two main phases: determining the region of interest,
I'm interested in determining if named groups were used in the pattern passed to
Is there a way of determining when a given user last logged into SQL
Interested in creating a timer to count up for the user. I was wondering
Interested if anyone has used VSTS Database Edition extensively and, if so, which features
Algorithm(a-array, n-length): for(i=2;i<=n;i++) if(a[1]<a[i]) Swap(a,1,i); for(i=n-1;i>=2;i--) if(a[n]<a[i]) Swap(a,n,i); I'm interested in determining how many
Interested in upgrading JAVA VERSION from JAVA 1.5 to JAVA 1.6 [oracle@server301 /]$ java
I interested to work with data types and file formats. For example I want
im interested how many api calls per second or per minute i can do
I am interested in doing this C code in Java: // sets n's ith

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.