Changes

Jump to: navigation, search

JavaScript Window Object

1,147 bytes added, 19:36, 9 May 2007
Moving and Resizing Windows
== Moving and Resizing Windows ==
 
A window can be moved to specific coordinates on the screen using the window object's ''moveTo()'' method which takes x and y coordinates as arguments. The following example move a new window to location 100, 200 on the screen when the "Move Window" button is pressed:
 
<pre>
 
<script language="JavaScript" type="text/javascript">
newWindowObj = window.open ("", "MyWindow");
 
</script>
 
<form action="null">
<input type="button" value="Move Window" onclick="newWindowObj.moveTo(100, 200)" />
</form>
 
</pre>
 
In addition to moving a window to a specific new location is is also possible to move a window relative to its current location on the screen using the ''moveBy()'' method of the JavaScript window object. Once again the method takes x and y values that are added to the current x and y coordinates of the specified window. Negative values can be used to change the direction of the movement:
 
<pre>
 
<script language="JavaScript" type="text/javascript">
newWindowObj = window.open ("", "MyWindow");
 
</script>
 
<form action="null">
<input type="button" value="Move Window" onclick="newWindowObj.moveTo(100, 200)" />
</form>
 
</pre>

Navigation menu