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.


Description

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 Edge Firefox Safari Opera IE
Yes Yes Yes Yes Yes Yes


Copyright 1999-2023 by Refsnes Data. All Rights Reserved.