I made the page body 200% high so that it fits twice on the screen. Using javascript, I make it scroll up or down when scrolling. To do this, I need to find out the lowest page scroll point in any browser or screen size so that it stops when it gets there.
No jQuery, please.
Thanks.
My code: (it is still compiling, so it takes a bit of work)
function getScrollXY() { var x = 0, y = 0; if( typeof( window.pageYOffset ) == 'number' ) { // Netscape x = window.pageXOffset; y = window.pageYOffset; } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) { // DOM x = document.body.scrollLeft; y = document.body.scrollTop; } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) { // IE6 standards compliant mode x = document.documentElement.scrollLeft; y = document.documentElement.scrollTop; } return [x, y]; } function scrollup() { if (xy[1] > 0) { window.scrollBy(0,-100); setTimeout(scrollup,200); } else { null; } } function scrolldown() { if (xy[1] < ) { window.scrollBy(0,100); setTimeout(scrolldown,200); } else { null; } } function dothescroll() { var xy = getScrollXY(); var y = xy[1]; setTimeout(function(){ if (xy[1] > y) { scrollup(); } else { scrolldown(); } },200); }
javascript scroll
Neil Philip Whitehead
source share