Window resizeTo() Method

Definition and Usage

resizeTo() The method adjusts the window size to the new width and height.

See also:

resizeBy() method

moveBy() method

moveTo() method

Example

Open a new window and resize it to 300 x 300:

function openWin() {
  myWindow = window.open("", "", "width=200, height=100");
}
function resizeWin() {
  myWindow.resizeTo(300, 300);
}

Try it yourself

Example

Use resizeTo() with resizeBy():

function resizeWinTo() {
  myWindow.resizeTo(800, 600);
}
function resizeWinBy() {
  myWindow.resizeBy(-100, -50);
}

Try it yourself

Syntax

window.resizeTo(width, height)

Parameters

Parameters Description
width Required. New window width in pixels.
height Required. New window height in pixels.

Return Value

None.

Browser Support

All Browsers Support resizeTo():

Chrome IE Edge Firefox Safari Opera
Chrome IE Edge Firefox Safari Opera
Support Support Support Support Support Support