X
HOME HTML5 CSS3 JAVASCRIPT SQL PHP5 JQUERY ANGULAR BOOTSTRAP3 XML MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

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

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB HOSTING

UK Reseller Hosting

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates

SHARE THIS PAGE

facebook