window.scrollBy() : Window Object : Window JAVASCRIPT TUTORIALS


JAVASCRIPT TUTORIALS » Window » Window Object »

 

window.scrollBy()










Syntax








window.scrollBy(numHort, numVert)



The scrollBy() method scrolls the window.

If the numbers passed are positive, the window is scrolled in the positive direction. Negative numbers are scrolled in the negative direction.












<html>
    <head>
    <script language="JavaScript1.2">
    <!--
    function scrollWin(dir, dist){
      var myVert;
      var myHorz;

      if(dir == "vert"){
        myHorz = 0;
        myVert = dist;
      }else{
        myHorz = dist;
        myVert = 0;
      }
      window.scrollBy(myHorz, myVert);
    }
    -->
    </script>
    </head>
    <body>
    <form>
    <table border=0>
      <tr>
        <td><input type=BUTTON value="Down" onClick="scrollWin('vert',10)"></td>
      </tr>
      <tr>
        <td><input type=BUTTON value="Left" onClick="scrollWin('horz',-10)"></td>
        <td><input type=BUTTON value="Right" onClick="scrollWin('horz',10)"></td>
      </tr>
      <tr>
        <td><input type=BUTTON value="Up" onClick="scrollWin('vert',-10)"></td>
      </tr>
    </table>
    </form>
    </body>
    </html>







HTML code for linking to this page:

Follow Navioo On Twitter

JAVASCRIPT TUTORIALS

 Navioo Window
» Window Object