Set div position in page scroll action : top : Style JAVASCRIPT TUTORIALS


JAVASCRIPT TUTORIALS » Style » top »

 

Set div position in page scroll action

















<html>
    <head>
        <title>OnScroll Example</title>
        <script type="text/javascript">
            window.onscroll = function () {
                var oWatermark = document.getElementById("divWatermark");
                oWatermark.style.top = document.body.scrollTop;
            }
        </script>
    </head>
    <body>
         <P>Try scrolling this window.</p>
         <div id="divWatermark" style="position: absolute; top: 0px; right: 0px; color: #cccccc; width: 150px; height: 30px; background-color: navy">www.navioo.com</div>
         <P>Line 1</p>
         <P>Line 2</p>
         <P>Line 3</p>
         <P>Line 4</p>
         <P>Line 5</p>
         <P>Line 6</p>
         <P>Line 7</p>
         <P>Line 8</p>
         <P>Line 9</p>
         <P>Line 10</p>
         <P>Line 11</p>
         <P>Line 12</p>
    </body>
</html>







HTML code for linking to this page:

Follow Navioo On Twitter

JAVASCRIPT TUTORIALS

 Navioo Style
» top