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


JAVASCRIPT TUTORIALS » Window » Window Object »

 

window.scroll()









Syntax








window.scroll(numX, numY)



The scroll() method scrolls the window.












<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.scroll(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