Javascript Browser Window resizeBy() Method

Introduction

Open a new window, and resize the width and height 250px relative to its current position:

Open a new window, and resize the width and height to 250px:

View in separate window

<!DOCTYPE html>
<html>
<body>

<button onclick="openWin()">Create window</button>
<button onclick="resizeWin()">Resize window</button>

<script>
var myWindow;//w  ww  .jav a  2s .  com

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

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

</body>
</html>

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

This method moves the bottom right corner of the window by the specified number of pixels defined.

The top left corner will not be moved.

resizeBy(width, height);

Parameter Values

Parameter Type Description
width Number Required. A positive or a negative number that specifies how many pixels to resize the width by
heightNumber Required. A positive or a negative number that specifies how many pixels to resize the height by



PreviousNext

Related