W3cubDocs

/DOM

window.moveTo

Moves the window to the specified coordinates.

Syntax

window.moveTo(x, y) 

Parameters

  • x is the horizontal coordinate to be moved to.
  • y is the vertical coordinate to be moved to.

Example

function origin() {
  // moves to top left corner of screen
  window.moveTo(0, 0);
}

Notes

This function moves the window absolutely while window.moveBy moves the window relative to its current location.

Since Firefox 7, it's no longer possible for a web site to move a window in a browser, according to the following rules:

  1. You can't move a window or tab that wasn’t created by window.open.
  2. You can't move a window or tab when it’s in a window with more than one tab.

Specification

Specification Status Comment
CSS Object Model (CSSOM) View Module
The definition of 'window.moveTo()' in that specification.
Working Draft Initial definition

Browser CompatibilityUpdate compatibility data on GitHub

Desktop
Chrome Edge Firefox Internet Explorer Opera Safari
Basic support Yes ? Yes ? ? ?
Mobile
Android webview Chrome for Android Edge Mobile Firefox for Android Opera for Android iOS Safari Samsung Internet
Basic support Yes Yes ? Yes ? ? ?

© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/window/moveTo