Javascript Reference - Window resizeTo() Method








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

Browser Support

resizeTo Yes Yes Yes Yes Yes

Syntax

window.resizeTo(width,height)

Parameter Values

Parameter Description
width Required. Sets the width in pixels
height Required. Sets the height in pixels




Return Value

No return value.

Example

The following code shows how to open a new window, and resize the width and height to 250px.


<!DOCTYPE html>
<html>
<body>
<button onclick="openWin()">Create window</button>
<button onclick="resizeWin()">Resize window</button>
<!--from   w w  w .ja  v a  2  s . c  o  m-->
<script>
var myWindow;

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

function resizeWin() {
    myWindow.resizeTo(250, 250);
    myWindow.focus();
}
</script>

</body>
</html>

The code above is rendered as follows: