Window resizeTo()Method

Window 对象参考手册Window Object

Examples

Create a window, set width and height to 500px:

var w; function openwindow(){ w=window.open('','', 'width=100,height=100'); w.focus(); } function myFunction(){ w.resizeTo(500,500); w.focus(); }

Try it Yourself »

Definition and Usage

This method is used to resize the window to the specified width and height.

Syntax

window.resizeTo(width,height)

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


Browser Support

All latest versions of browsers support the resizeTo() method.

Chrome Edge Firefox Safari Opera IE
Supported Supported Supported Supported Supported Supported

Example

Example

Use resizeBy() and resizeTo():

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

Try it Yourself »


Window 对象参考手册Window Object Other Extensions