<p>I'm looking for a cross-browser method of detecting that a client web browser is scrolled all the way to the bottom (or top) of the screen.</p>

<p>Really, the top is fairly easy, as<br>
    <code>scrY = window.pageYOffset || document.body.scrollTop || document.documentElement.scrollTop</code><br>
is zero if you're at the top.  The problem is that scrY seems to return the top of the scroll bar, and not the bottom, so instead of getting something equivalent to the height of the document (in pixels) I what is presumably the height of the document less the size of the scroll bar.</p>

<p>Is there an easy, cross-browser way to find out if the user has scrolled down to the bottom of the document/window?  Most specifically, I understand general scroll bar manipulation (setting it, moving it, etc.) but how can I get the delta of the bottom of the scrollbar's position relative to the bottom of the window/document.  </p>

http://www.softcomplex.com/docs/get_window_size_and_scrollbar_position.html
http://www.sitepoint.com/article/preserve-page-scroll-position/
http://codepunk.hardwar.org.uk/ajs02.htm
In order to ensure that an element is visible, you can use the
.scrollIntoView method