Window: resizeTo() method
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
TheWindow.resizeTo() method dynamically resizes thewindow.
In this article
Syntax
resizeTo(width, height)Parameters
widthAn integer representing the new
outerWidthinpixels (including scroll bars, title bars, etc.).heightAn integer value representing the new
outerHeightin pixels (including scroll bars,title bars, etc.).
Return value
None (undefined).
Examples
This function resizes the window so that it takes up one quarter of the availablescreen. See theScreen.availWidth andScreen.availHeightproperties.
function quarter() { window.resizeTo(window.screen.availWidth / 2, window.screen.availHeight / 2);}Specifications
| Specification |
|---|
| CSSOM View Module> # dom-window-resizeto> |
Browser compatibility
Note: It's not possible to resize a window or tab that wasn't created bywindow.open(). It's also not possible to resize when thewindow has multiple tabs.
Note:This function might not resize the window synchronously.In some environments (like mobile) it might not resize the window at all. Youcan listen to theresize event to seeif/when the window got resized.