topical media & game development

talk show tell print

professional-javascript-09-OnScrollExample4.htm / htm



  <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">Watermark</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>
  


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.