[Javascript] innerwidth
J. Lester Novros II
lester at denhaag.org
Thu May 23 21:04:33 CDT 2002
Dear Andrew,
On 05/24/2002 03:09 AM, Andrew Dunn wrote:
> Hi,
> I have a loop as follows, which scrolls to the end of the page slowly:
>
> function startScrolling ()
> {
> window.scrollBy(1,0);
This statement would scroll the page horizontally; 'scrollBy(0, 1);' would
scroll vertically.
> When the browser gets to the end of the page I want it to go back to the
> beginning, but I can't figure out how to do it. I thought about using
> innerWidth and a counter (i) but I can't get the innerWidth to work: here is
> a link to the page:
Try doing it this way:
function startScrolling()
{
window.scrollBy(0, 1);
if ((innerHeight + pageYOffset) < document.body.offsetHeight)
setTimeout ('startScrolling()', 60);
else
window.scrollTo(0, 0);
}
'pageYOffset' returns the amount that the page has been scrolled vertically,
i.e. the distance between the document top and the top of the canvas a.k.a.
client area; 'innerHeight' is the height of the canvas.
Hope this helps.
l8R lES
--
Since 1998, a federal judge ordered a breakup, an appeals court threw out that
order, and a new judge took responsibility; yet even with 2 courts finding that
m$ violated the Antitrust Act, no remedy has been put into effect. cNet News
http://open.denhaag.nu http://www.denhaag.org
More information about the Javascript
mailing list