HTML | Window resizeTo() Method

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

Syntax:

window.resizeTo(width, height)

Parameter Values:



  • width: Sets the width of the window, in pixels.
  • height: Sets the height of the window, in pixels.

Example: Resize the window.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
  
<head>
    <title>
        Window resizeTo() Method
    </title>
    <style>
        h1 {
            color: green;
        }
    </style>
  
</head>
  
<body>
    <center>
        <h1>Geeks for Geeks</h1>
        <button onclick="openWin()">
            New window
        </button>
        <button onclick="resizeWin()">
            Resize window
        </button>
  
        <script>
            var myWindow;
  
            function openWin() {
                myWindow =
                    window.open("", "",
                        "width=100, height=100");
            }
  
            function resizeWin() {
                myWindow.resizeTo(300, 300);
                myWindow.focus();
            }
        </script>
    </center>
</body>
  
</html>

chevron_right


Output:
Initial:

New window:

Resize window:

Supported Browsers: The browser supported by Window resizeTo() Method are listed below:

  • Google Chrome
  • Internet Explorer
  • Mozilla Firefox
  • Opera
  • Safari


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.