Window moveTo()
Example
Open a new window, and move it to position 500 x 100:
function openWin()
{
myWindow = window.open('', '', 'width=400, height=200');
}
function moveWin()
{
myWindow.moveTo(500, 100);
}
Try it Yourself »
More examples below.
Definition and Usage
The moveTo()
method moves a window to the specified coordinates.
Syntax
window.moveTo(x, y)
Parameters
Parameter | Description |
x | Required. A positive or negative number. The horizontal coordinate to move to. |
y | Required. A positive or negative number. The vertical coordinate to move to. |
Return Value
NONE |
More Examples
Using moveTo() together with moveBy():
function moveWinTo() {
myWindow.moveTo(150, 150);
}
function moveWinBy() {
myWindow.moveBy(75, 50);
}
Try it Yourself »
Browser Support
moveTo()
is supported in all browsers:
Chrome | IE | Edge | Firefox | Safari | Opera |
Yes | Yes | Yes | Yes | Yes | Yes |