Movatterモバイル変換


[0]ホーム

URL:


MDN Web Docs

Window: resizeBy() method

BaselineWidely available

TheWindow.resizeBy() method resizes the current windowby a specified amount.

Syntax

js
resizeBy(xDelta, yDelta)

Parameters

xDelta

The number of pixels to grow the window horizontally.

yDelta

The number of pixels to grow the window vertically.

Return value

None (undefined).

Examples

js
// Shrink the windowwindow.resizeBy(-200, -200);

Notes

This method resizes the window relative to its current size. To resize the window inabsolute terms, usewindow.resizeTo().

Creating and resizing an external window

For security reasons, it's no longer possible in Firefox for a website to change thedefault size of a window in a browser if the window wasn't created bywindow.open(), or contains more than one tab. See the compatibility tablefor details on the change.

Even if you create window bywindow.open()it is not resizable bydefault. To make the window resizable, you must open it with the"resizable" feature.

js
// Create resizable windowmyExternalWindow = window.open(  "https://example.com",  "myWindowName",  "resizable",);// Resize window to 500x500myExternalWindow.resizeTo(500, 500);// Make window relatively smaller to 400x400myExternalWindow.resizeBy(-100, -100);

The window you create must respect the Same Origin Policy. If the window you open isnot in the same origin as the current window, you will not be able to resize, or accessany information on, that window/tab.

Specifications

Specification
CSSOM View Module
# dom-window-resizeby

Browser compatibility

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.

Help improve MDN

Learn how to contribute.

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp