window.onscroll = function (e) {
// called when the window is scrolled.
}
<html>
<head>
<title>onscroll test</title>
<script type="text/javascript">
window.onscroll = scroll;
function scroll()
{
alert("scroll event detected! "+window.pageXOffset+" "+window.pageYOffset);
// note: you can use window.innerWidth and window.innerHeight to access the width and height of the viewing area
}
</script>
</head>
<body>
<p>Resize the window</p>
<p>to a very small size,</p>
<p>and use the scrollbars</p>
<p>to move around the page content</p>
<p>in the window.</p>
</body>
</html>
bug 189308 , in older versions of Gecko caused onscroll to be fired only when dragging the scroll bar, not when using cursor keys or mousewheel. This was fixed in Gecko 1.8/Firefox 1.5.
When the window.scrollX/scrollY isn't 0 -- meaning that some scrolling occurred by either script or manual action -- reloading the current page will trigger the onscroll event immediately.
Page last modified 04:55, 16 Apr 2008 by Johnjbarton?