Window.moveTo()

Baseline Widely available *

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

* Some parts of this feature may have varying levels of support.

moveTo()Window インターフェイスのメソッドで、現在のウィンドウを指定された座標へ移動します。

メモ: この関数はウィンドウを絶対位置へ移動します。それに対して、 window.moveBy() はウィンドウを現在の位置からの相対位置へ移動します。

構文

js
moveTo(x, y);

引数

  • x は移動先の水平座標です。
  • y は移動先の垂直座標です。

返値

なし (undefined)。

この例では、ウィンドウを画面の左上に移動しています。

js
function origin() {
  window.moveTo(0, 0);
}

仕様書

Specification
CSSOM View Module
# dom-window-moveto

ブラウザーの互換性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
moveTo
Moved relative to the Multi-screen origin

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
Partial support
Partial support
See implementation notes.

Firefox 7 より、ウェブサイトは以下の場合にブラウザーウィンドウを移動できなくなりました。

  1. Window.open() で作成されたものではないウィンドウやタブを移動することはできません。
  2. ウィンドウに複数のタブがある場合は、ウィンドウやタブを移動することができません。

関連情報