JavaScript 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.

  • Front-end engineers work closely with designers to make websites beautiful, functional, and fast.
    • Includes 34 Courses
    • With Professional Certification
    • Beginner Friendly.
      115 hours
  • Learn how to use JavaScript — a powerful and flexible programming language for adding website interactivity.
    • Beginner Friendly.
      15 hours

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

  • Front-end engineers work closely with designers to make websites beautiful, functional, and fast.
    • Includes 34 Courses
    • With Professional Certification
    • Beginner Friendly.
      115 hours
  • Learn how to use JavaScript — a powerful and flexible programming language for adding website interactivity.
    • Beginner Friendly.
      15 hours