The Window.resizeTo()
method dynamically resizes the window.
The Window.resizeTo()
method dynamically resizes the window.
js
resizeTo(width, height)
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.).
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.
js
function quarter() { window.resizeTo(window.screen.availWidth / 2, window.screen.availHeight / 2); }
Specification |
---|
CSSOM View Module # dom-window-resizeto |
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.
© 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