Movatterモバイル変換


[0]ホーム

URL:


MDN Web Docs

Window: resizeTo() method

BaselineWidely available

TheWindow.resizeTo() method dynamically resizes thewindow.

Syntax

js
resizeTo(width, height)

Parameters

width

An integer representing the newouterWidth inpixels (including scroll bars, title bars, etc.).

height

An integer value representing the newouterHeight in 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.

js
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.

See also

Help improve MDN

Learn how to contribute.

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp