X
HOME HTML CSS JAVASCRIPT SQL PHP JQUERY XML ASP.NET MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

Window resizeTo() Method

Window Object Reference Window Object

Example

Open a new window, and resize the 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 »


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

Internet Explorer Firefox Opera Google Chrome Safari

The resizeTo() method is supported in all major browsers.


Syntax

window.resizeTo(width,height)

Parameter Values

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

Return Value

No return value.


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

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates FREE Website Templates Free HTML Templates

SHARE THIS PAGE

facebook