The moveTo() method of the Window interface moves the current window to the specified coordinates.
Note: This function moves the window to an absolute location. In contrast, window.moveBy() moves the window relative to its current location.
Syntax
window.moveTo(x, y)
Parameters
xis the horizontal coordinate to be moved to.yis the vertical coordinate to be moved to.
Example
This example moves the window to the top-left corner of the screen.
function origin() {
window.moveTo(0, 0);
}
Specification
| Specification | Status | Comment |
|---|---|---|
| CSS Object Model (CSSOM) View Module The definition of 'window.moveTo()' in that specification. |
Working Draft | Initial definition |
Browser compatibility
The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
moveTo | Chrome Full support Yes | Edge Full support 12 | Firefox Full support Yes | IE ? | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support Yes | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes |
Legend
- Full support
- Full support
- Compatibility unknown
- Compatibility unknown
As of Firefox 7, websites can no longer move a browser window in the following cases:
- You can't move a window or tab that wasnβt created by
Window.open(). - You can't move a window or tab when itβs in a window with more than one tab.
