Window moveBy() method
- Previous Page matchMedia()
- Next Page moveTo()
- Go to the Previous Level Window Object
Definition and usage
moveBy()
The method moves the window by a certain number of pixels relative to its current coordinates.
See also:
Instance
Example 1
Open a new window and move it 250 pixels relative to the current position:
function openWin() { myWindow = window.open('', '', 'width=400, height=400'); } function moveWin() { myWindow.moveBy(250, 250); }
Example 2
Use moveBy() and moveTo() together:
function moveWinTo() { myWindow.moveTo(150, 150); } function moveWinBy() { myWindow.moveBy(75, 75); }
Syntax
window.moveBy(x, y)
Parameter
Parameter | Description |
---|---|
x | Mandatory. Positive or negative number. Number of pixels for horizontal movement of the window. |
y | Required. A positive or negative number. The number of pixels to move the window vertically. |
Return Value
None.
Browser Support
All Browsers Support moveBy()
:
Chrome | IE | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
Chrome | IE | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support | Support |
- Previous Page matchMedia()
- Next Page moveTo()
- Go to the Previous Level Window Object