English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
moveBy()The method moves the window by a specified number of pixels relative to its current coordinates.
This method moves the window relative to its current position. Conversely,window.moveTo()Move the window to an absolute position.
window.moveBy(x, y)
// Function to open a new window function windowOpen() { popupWindow = window.open("", "", "width=200, height=200"); } //Function to move an open window function windowMove() { popupWindow.moveBy(200, 200); popupWindow.focus(); }Test and See‹/›
The moveBy() method is fully supported by all browsers:
Method | |||||
moveBy() | Yes | Yes | Yes | Yes | Yes |
Parameter | Description |
---|---|
x | Number of pixels to move the window horizontally. Positive values are on the right, and negative values are on the left |
y | Number of pixels to move the window vertically. Positive values move down, and negative values move up |
Return Value: | None |
---|
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‹/›
Window (Window) Reference:moveTo() method
Window (Window) Reference:resizeBy() method
Window (Window) Reference:resizeTo() method