resizeBy()

Anonymous contributor's avatar
Anonymous contributor
Published Feb 14, 2025
Contribute to Docs

The resizeBy() function under the window object resizes the browser window by a specified number of pixels relative to its current size.

Syntax

window.resizeBy(widthDelta, heightDelta);
  • widthDelta: The number of pixels to increase or decrease the window’s width. Positive values increase the width, negative values decrease it.
  • heightDelta: The number of pixels to increase or decrease the window’s height. Positive values increase the height, negative values decrease it.

Example

In this example, the window size will increase by 100 pixels in width and 50 pixels in height:

window.resizeBy(100, 50);

All contributors

Contribute to Docs

Learn JavaScript on Codecademy