Javascript examples for Browser Object Model:Window moveBy
The moveBy() method moves a window a specified number of pixels relative to its current coordinates.
Parameter | Type | Description |
---|---|---|
x | Number | Required. A positive or negative number to move the window horizontally |
y | Number | Required. A positive or negative number to move the window vertically |
No return value
The following code shows how to Open a new window, and move the new window 250px relative to its current position:
<!DOCTYPE html> <html> <body> <button onclick="openWin()">Open "myWindow"</button> <button onclick="moveWin()">Move "myWindow"</button> <script> var myWindow;//from ww w.j a v a 2 s . c o m function openWin() { myWindow = window.open("", "myWindow", "width=200, height=100"); myWindow.document.write("<p>This is 'myWindow'</p>"); } function moveWin() { myWindow.moveBy(250, 250); myWindow.focus(); } </script> </body> </html>