THE WORLD'S LARGEST WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

Window resizeTo() Method

Window Object Reference Window Object

Example

Open a new window, and set its width and height to 250px:

function openWin() {
    myWindow = window.open("", "", "width=100, height=100");  // Opens a new window
}

function resizeWin() {
    myWindow.resizeTo(250, 250);                             // Resizes the new window
    myWindow.focus();                                        // Sets focus to the new window
}
Try it Yourself »

More "Try it Yourself" examples below.


Definition and Usage

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

Related methods:

  • resizeBy() - Resizes the window by the specified pixels
  • moveBy() - Moves a window relative to its current position
  • moveTo() - Moves a window to the specified position

Browser Support

Method
resizeTo() Yes Yes Yes Yes Yes

Syntax

window.resizeTo(width,height)

Parameter Values

Parameter Type Description
width Number Required. Sets the width of the window, in pixels
height Number Required. Sets the height of the window, in pixels

Technical Details

Return Value: No return value

Examples

More Examples

Example

Using the resizeTo() method together with resizeBy():

function resizeWinTo() {
    myWindow.resizeTo(800, 600);
    myWindow.focus();
}

function resizeWinBy() {
    myWindow.resizeBy(-100, -50);
    myWindow.focus();
}
Try it Yourself »

Window Object Reference Window Object