The HTML Window resizeBy() method resize the window relative to its current size by the specified values.
Syntax
Following is the syntax −
window.resizeBy(w,h)
Here, w and h define the value of resizing the window width and height in pixels respectively.
Let us see an example of HTML Window resizeBy() Method −
Example
<!DOCTYPE html> <html> <style> body { color: #000; height: 100vh; background-color: #8BC6EC; background-image: linear-gradient(135deg, #8BC6EC 0%, #9599E2 100%) no-repeat; text-align: center; } .btn { background: #db133a; border: none; height: 2rem; border-radius: 2px; width: 20%; display: block; color: #fff; outline: none; cursor: pointer; margin: 1rem auto; } </style> <body> <h1>HTML Window resizeBy() Method Demo</h1> <button onclick="create()" class="btn">Create a new window</button> <button onclick='resize()' class="btn">Resize the window</button> <script> var newWindow; function create(){ newWindow =window.open('','','width=80,height=80'); } function resize(){ newWindow.resizeBy(100, 100); newWindow.focus(); } </script> </body> </html>
Output
Click on “Create a new window” button to generate a new window:
Now click on “Resize the window” button to resize the newly created window −