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.
The moveTo()
method moves a window to the specified coordinates.
window.moveTo(
x, y)
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. |
NONE |
Using moveTo() together with moveBy():
function moveWinTo() {
myWindow.moveTo(150, 150);
}
function moveWinBy() {
myWindow.moveBy(75, 50);
}
Try it Yourself »
moveTo()
is supported in all browsers:
Chrome | Edge | Firefox | Safari | Opera | IE |
Yes | Yes | Yes | Yes | Yes | Yes |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!