Window resizeBy()
Example 1
Open a new window, and resize (increase) the width and height:
function openWin() {
myWindow = window.open("", "", "width=100, height=100");
}
function resizeWin() {
myWindow.resizeBy(250, 250);
}
Try it Yourself »
More examples below.
Definition and Usage
The resizeBy()
method resizes a window by a specified amount.
Syntax
resizeBy(width, height)
Parameters
Parameter | Description |
width | Required. A positive or a negative number. The number of pixels to resize the width by. |
height | Required. A positive or a negative number. The number of pixels to resize the height by. |
Return Value
NONE |
More Examples
Open a new window, and decrease the width by 50px and increase the height by 50px:
myWindow.resizeBy(-50, 50);
Try it Yourself »
Using resizeBy() with resizeTo():
function resizeWinTo() {
myWindow.resizeTo(800, 600);
myWindow.focus();
}
function resizeWinBy() {
myWindow.resizeBy(-100, -50);
}
Try it Yourself »
Browser Support
resizeBy()
is supported in all browsers:
Chrome | Edge | Firefox | Safari | Opera | IE |
Yes | Yes | Yes | Yes | Yes | Yes |