JavaScript .resizeTo()

atidua's avatar
Published Feb 18, 2025Updated Mar 4, 2025
Contribute to Docs

The .resizeTo() function in JavaScript modifies the browser window’s dimensions based on the specified width and height values in pixels.

  • 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.resizeTo(width, height);
  • width: Defines the new width of the window in pixels.
  • height: Defines the new height of the window in pixels.

Example

The example below demonstrates the use of the .resizeTo() function:

window.resizeTo(450, 300);

The above example will resize the window to a width of 450 pixels and height of 300 pixels.

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