English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Window moveTo() method

JavaScript Window Object

moveTo()moves the current window to the specified coordinates.

This method moves the window to an absolute position. In contrast,window.moveBy()Move the window relative to its current position.

Syntax:

window.moveTo(x, y)
// Function to open a new window
function windowOpen() {
  popupWindow = window.open("", "", "width=")200, height=200");
}
// Function to move the opened window
function windowMove() {
  popupWindow.moveTo(200, 200);
  popupWindow.focus();
}
Test and See‹/›

Browser Compatibility

All browsers fully support the moveTo() method:

Method
moveTo()IsIsIsIsIs

Parameter Value

ParameterDescription
xThe horizontal coordinate to move to
yThe vertical coordinate to move to

Technical Details

Return Value:None

More Examples

This example combines moveBy() with moveTo():

function windowMoveTo() {
  popupWindow.moveTo(150, 150);
  popupWindow.focus();
}
function windowMoveBy() {
  popupWindow.moveBy(100, 100);
  popupWindow.focus();
}
Test and See‹/›

Related References

Window (Window) Reference:moveBy() method

Window (Window) Reference:resizeBy() method

Window (Window) Reference:resizeTo() method

JavaScript Window Object