Mega Code Archive

 
Categories / JavaScript Tutorial / Window
 

Window moveBy()

Syntax window.moveBy(numHort, numVert) The moveBy() method moves the window by the number of pixels. The first numeric value represents the vertical pixels, while the second numeric value represents the horizontal number of pixels. If the numbers passed are positive, the window is moved to the right horizontally, and up vertically. Negative numbers move the window in the opposite direction. <html>     <script language="JavaScript1.2">     <!--     function moveWin(dir, dist){       var myVert;       var myHorz;       if(dir == "vert"){         myHorz = 0;         myVert = dist;       }else{         myHorz = dist;         myVert = 0;       }       window.moveBy(myHorz, myVert);     }     -->     </script>     <body>     <form>     <table border=0>       <tr>         <td><input type=BUTTON value="  Up  " onClick="moveWin('vert',-1)"></td>       </tr>       <tr>         <td><input type=BUTTON value=" Left " onClick="moveWin('horz',-1)"></td>         <td><input type=BUTTON value="Right" onClick="moveWin('horz',1)"></td>       </tr>       <tr>         <td><input type=BUTTON value="Down" onClick="moveWin('vert',1)"></td>       </tr>     </table>     </form>     </body>     </html>