Javascript Reference - Window resizeBy() Method








The resizeBy() method resizes a window by the specified amount, relative to its current size.

Browser Support

resizeBy Yes Yes Yes Yes Yes

Syntax

resizeBy(width, height)

Parameter Values

Parameter Description
width Required. A positive or a negative number of pixels to resize the width
height Required. A positive or a negative number of pixels to resize the height




Return Value

No return value.

Example

The following code shows how to Open a new window, and resize the width and height 250px relative to its current position.


<!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.resizeBy(250, 250);
    myWindow.focus();
}
</script>

</body>
</html>

The code above is rendered as follows: