The Window.resizeTo() method dynamically resizes the window.
On this page
Window: resizeTo() method
Syntax
js
resizeTo(width, height)
Parameters
-
width -
An integer representing the new
outerWidthin pixels (including scroll bars, title bars, etc.). -
height -
An 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 available screen. See the Screen.availWidth and Screen.availHeight properties.
js
function quarter() {
window.resizeTo(window.screen.availWidth / 2, window.screen.availHeight / 2);
}
Specifications
| Specification |
|---|
| CSSOM View Module # dom-window-resizeto |
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 |
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.
|
4 | ≤12.1 | 1 | 4.4 | 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–2023 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