Moving Windows


Moving Windows

You can use the moveBy and moveTo methods to move windows. The moveBy method moves a window by a given (positive or negative) X and Y offset, and the moveTo method moves a window to a specific X and Y location. Both methods take two argumentsthe X and Y offset (for moveBy ) or new position (for moveTo ), measured in pixels.

X and Y coordinates for the moveBy and moveTo methods are measured in screen coordinates, where (0, 0) is the upper-left corner of the screen; positive X is to the right, and positive Y is downward. To move 10 pixels down and 5 pixels to the left, for example, use moveBy(-5, 10) . Note that this is true for all JavaScript graphical methods: (0, 0) is at upper left (the upper left of the screen for the moveBy and moveTo methods, but possibly the upper left of other windowssuch as the browser windowfor certain other methods), positive X is to the right, and positive Y is downward.

Here's an example that moves the browser to the upper-left corner of the screen:

(Listing 08-04.html on the web site)
 <HTML>      <HEAD>          <TITLE>Using the moveTo method</TITLE>          <SCRIPT LANGUAGE="JavaScript">              <!--  function mover()   {   window.moveTo(0, 0)   }  // -->          </SCRIPT>      </HEAD>      <BODY>          <H1>Using the moveTo method</H1>          <FORM>              <INPUT TYPE="BUTTON" ONCLICK="mover()" VALUE="Click Me!">          </FORM>      </BODY>  </HTML> 


Inside Javascript
Inside JavaScript
ISBN: 0735712859
EAN: 2147483647
Year: 2005
Pages: 492
Authors: Steve Holzner

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net