Window moveBy()
Example
Open a new window and move it 250px relative to its current position:
function openWin()
{
myWindow = window.open('', '', 'width=400, height=400');
}
function moveWin()
{
myWindow.moveBy(250, 250);
}
Try it Yourself »
More examples below.
Description
The moveBy()
method moves a window a number of pixels relative to its current coordinates.
Syntax
window.moveBy(x, y)
Parameters
Parameter | Description |
x | Required. A positive or negative number. The number of pixels to move the window horizontally. |
y | Required. A positive or negative number. The number of pixels to move the window vertically. |
Return Value
NONE |
More Examples
Using moveBy() together with moveTo():
function moveWinTo() {
myWindow.moveTo(150, 150);
}
function moveWinBy() {
myWindow.moveBy(75, 75);
}
Try it Yourself »
Browser Support
moveBy()
is supported in all browsers:
Chrome | Edge | Firefox | Safari | Opera | IE |
Yes | Yes | Yes | Yes | Yes | Yes |