Window.moveBy()
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.
moveBy()
は Window
インターフェイスのメソッドで、現在のウィンドウを指定された量だけ移動します。
メモ:
この関数はウィンドウを現在の位置からの相対位置で移動します。
それに対して、 window.moveTo()
はウィンドウを絶対位置へ移動します。
構文
js
moveBy(deltaX, deltaY);
引数
deltaX
は、ピクセル数でウィンドウを水平方向に移動させる量を示します。正の値は右へ、負の値は左へ移動します。deltaY
は、ピクセル数でウィンドウを垂直方向に移動させる量を示します。正の値は下方向、負の値は上方向です。
返値
なし (undefined
)。
例
この例では、ウィンドウを右に 10 ピクセル、上に 10 ピクセル移動させています。
js
function budge() {
moveBy(10, -10);
}
仕様書
Specification |
---|
CSSOM View Module # dom-window-moveby |
ブラウザーの互換性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
moveBy |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on 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.
Firefox 7 より、ウェブサイトは以下の場合にブラウザーウィンドウを移動できなくなりました。
Window.open()
で作成されたものではないウィンドウやタブを移動することはできません。- ウィンドウに複数のタブがある場合は、ウィンドウやタブを移動することができません。