Window.resizeTo()

The Window.resizeTo() method dynamically resizes the window.

Syntax

window.resizeTo(width, height)

Parameters

width

An integer representing the new outerWidth in pixels (including scroll bars, title bars, etc).

height

An integer value representing the new outerHeight in pixels (including scroll bars, title bars, etc).

Example

This function resizes the window so that it takes up one quarter of the available screen. See the Screen.availWidth and Screen.availHeight properties.

function quarter() {
  window.resizeTo(
    window.screen.availWidth / 2,
    window.screen.availHeight / 2
  );
}

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
resizeTo
1
12
1
Since Firefox 7, it's no longer possible for a web site to change the default size of a window in a browser if the window wasn't created by window.open or contains more than one tab. See here for more details.
4
≤12.1
1
1
18
4
≤12.1
1
1.0

Note: It's not possible to resize a window or tab that wasn’t created by window.open(). It's also not possible to resize when the window has multiple tabs.

See also

© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/Window/resizeTo