JavaScript window.resizeTo() Method

You are Here:

JavaScript window.resizeTo() Method

The window.resizeTo() method dynamically resizes a window to the specified width and height.

Example

HTML Online Editor
<!DOCTYPE html> <html> <body> <button onclick="myOpen()">Open Window</button> <button onclick="myResizeTo()">ResizeTo Window</button> <script> var myWindow; function myOpen(){ myWindow = window.open("","myWindow","width=100, height=150"); } function myResizeTo(){ myWindow.resizeTo(400, 400); myWindow.focus(); } </script> </body> </html>

Syntax

window.resizeTo(width, height)

Parameter Values

ValueTypeExplanation
widthRequiredAn integer value representing the new outerWidth in pixels (including scroll bars, title bars, etc).
heightRequiredAn integer value representing the new outerHeight in pixels (including scroll bars, title bars, etc).

resizeBy() vs resizeTo()

Example

HTML Online Editor
<!DOCTYPE html> <html> <body> <button onclick="myOpen()">Open Window</button> <button onclick="myResizeTo()">ResizeTo Window</button> <button onclick="myResizeBy()">ResizeBy Window</button> <script> var myWindow; function myOpen(){ myWindow = window.open("","myWindow","width=100, height=150"); } function myResizeTo(){ myWindow.resizeTo(400, 400) myWindow.focus(); } function myResizeBy(){ myWindow.resizeBy(50, 75); myWindow.focus(); } </script> </body> </html>

Reminder

Hi Developers, we almost covered 97% of JavaScript Tutorials with examples for quick and easy learning.

We are working to cover every Single Concept in JavaScript.

Please do google search for:

Join Our Channel

Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.

This channel is primarily useful for Full Stack Web Developer.

Share this Page

Meet the Author