This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
The Window.resizeTo() method dynamically resizes the window.
resizeTo(width, height)
widthAn integer representing the new outerWidth in pixels (including scroll bars, title bars, etc.).
heightAn integer value representing the new outerHeight in pixels (including scroll bars, title bars, etc.).
None (undefined).
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);
}
| Specification |
|---|
| CSSOM View Module> # dom-window-resizeto> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
resizeTo |
1 | 12 | 1Since 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 bywindow.open or contains more than one tab. See here for more details. |
≤12.1 | 1 | 18 | 4 | ≤12.1 | 1 | 1.0 | 4.4 | 1 |
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.
Note: This function might not resize the window synchronously. In some environments (like mobile) it might not resize the window at all. You can listen to the resize event to see if/when the window got resized.
© 2005–2025 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