You are here: Reference > JavaScript > client-side > browser > methods > resizeBy (window)

resizeBy method (window)

Browser support:
Resizes the browser window by the specified amount of pixels, relative to its current size.
The resizeBy method leaves the top-left corner of the browser window in place, it moves the other corners if necessary.
  • If you want to resize the browser window to a specified size, use the resizeTo method.
  • The browser window can be moved with the moveBy and moveTo methods.
  • To get the size and the top-left corner of the browser window, use the outerWidth, outerHeight and the screenX, screenY properties.
  • If you need information about the dimensions of the screen, use the screen object.

Syntax:

object.resizeBy (X, Y);
You can find the related objects in the Supported by objects section below.

Parameters:

X
Required. Integer that specifies the horizontal amount, in pixels. Negative values are also allowed.
Y
Required. Integer that specifies the vertical amount, in pixels. Negative values are also allowed.

Return value:

This method has no return value.

Example HTML code 1:

This example illustrates the use of the resizeBy and resizeTo methods:
<head>
    <script type="text/javascript">
        function ResizeBrowserBy () {
            window.resizeBy (-50, -50);
        }
        function ResizeBrowserTo () {
            window.resizeTo (600, 400);
        }
    </script>
</head>
<body>
    <button onclick="ResizeBrowserBy ();">Make the browser window smaller!</button>
    <br />
    <button onclick="ResizeBrowserTo ();">Resize the browser window to 600px * 400px</button>
</body>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content