I am running in a bit of a problem here trying to figure out this one. I already coded a jquery function that detects when the user hits the bottom of the page and trigger an function. Now, while this works alright for the most mon screen-sizes, it will not work when the user has a screen so big that sees the entire page at once, rendering the previous function useless.
What I am trying to achive is the fallback for those cases, how can I tell if the user has such a screensize that will trigger the function and leave the rest to the other?
Better explained: How to detect if the user browser-height is equal or greater than the page body height?
Sorry if this looks a bit confusing.
PS: The following code is the one I am using when the browser-height is smaller than the page body-height.
if ($('body').height() <= ($(window).height() + $(window).scrollTop())) {
//run function here when the browser-height is smaller than
//the page's height and it has reached the bottom
}
I am running in a bit of a problem here trying to figure out this one. I already coded a jquery function that detects when the user hits the bottom of the page and trigger an function. Now, while this works alright for the most mon screen-sizes, it will not work when the user has a screen so big that sees the entire page at once, rendering the previous function useless.
What I am trying to achive is the fallback for those cases, how can I tell if the user has such a screensize that will trigger the function and leave the rest to the other?
Better explained: How to detect if the user browser-height is equal or greater than the page body height?
Sorry if this looks a bit confusing.
PS: The following code is the one I am using when the browser-height is smaller than the page body-height.
if ($('body').height() <= ($(window).height() + $(window).scrollTop())) {
//run function here when the browser-height is smaller than
//the page's height and it has reached the bottom
}
Share
Improve this question
edited Apr 12, 2012 at 19:49
Shadow
asked Apr 12, 2012 at 19:42
ShadowShadow
4,7926 gold badges59 silver badges79 bronze badges
2 Answers
Reset to default 7 if ($(document).height() <= $(window).height() ) { }
$(document).height(); // returns height of HTML document
Use document height instead.
if ($(document).height() <= $(window).height())
{..}