Use window.onscroll to add the onscroll event handler : onscroll « Window « JavaScript Tutorial






<html>
    <head>
        <title>OnScroll Example</title>
        <script type="text/javascript">
            window.onscroll = function () {
                alert("scrolling");
            }
        </script>
    </head>
    <body>
         <P>Try scrolling this window.</p>
         <P>Try scrolling this window.</p>
         <P>Try scrolling this window.</p>
         <P>Try scrolling this window.</p>
         <P>Try scrolling this window.</p>
         <P>Try scrolling this window.</p>
         <P>Try scrolling this window.</p>
         <P>Try scrolling this window.</p>
         <P>Try scrolling this window.</p>
         <P>Try scrolling this window.</p>
         <P>Try scrolling this window.</p>
         <P>Try scrolling this window.</p>
         <P>Try scrolling this window.</p>
         <P>Try scrolling this window.</p>
         <P>Try scrolling this window.</p>
         <P>Try scrolling this window.</p>
         <P>Try scrolling this window.</p>
         <P>Try scrolling this window.</p>
         <P>Try scrolling this window.</p>
         <P>Try scrolling this window.</p>
         <P>Try scrolling this window.</p>
    </body>
</html>








19.11.onscroll
19.11.1.Use window.onscroll to add the onscroll event handler