Open In App

HTML DOM Window resizeTo() Method

The HTML Window resizeTo() Method is used to resize a window to the specified width and height. 

Syntax:



window.resizeTo(width, height)

Parameters:

Example: In this example, we will resize the window by using the Window resize To() method. 






<h1 style="color: green">GeeksforGeeks</h1>
<p>
    Click the new window button to create a window
    and Resize Window button to resize the window
</p>
<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>

Output: 

 

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

We have a Cheat Sheet on Javascript where we covered all the important topics of Javascript to check those please go through Javascript Cheat Sheet-A Basic guide to JavaScript.

Article Tags :