Baseline Widely available
The Window.resizeBy()
method resizes the current window by a specified amount.
xDelta
The number of pixels to grow the window horizontally.
yDelta
The number of pixels to grow the window vertically.
None (undefined
).
// Shrink the window
window.resizeBy(-200, -200);
Notes
This method resizes the window relative to its current size. To resize the window in absolute terms, use window.resizeTo()
.
For security reasons, it's no longer possible in Firefox for a website to change the default size of a window in a browser if the window wasn't created by window.open()
, or contains more than one tab. See the compatibility table for details on the change.
Even if you create window by window.open()
it is not resizable by default. To make the window resizable, you must open it with the "resizable"
feature.
// Create resizable window
myExternalWindow = window.open(
"https://example.com",
"myWindowName",
"resizable",
);
// Resize window to 500x500
myExternalWindow.resizeTo(500, 500);
// Make window relatively smaller to 400x400
myExternalWindow.resizeBy(-100, -100);
The window you create must respect the Same Origin Policy. If the window you open is not in the same origin as the current window, you will not be able to resize, or access any information on, that window/tab.
Specifications Browser compatibilityNote: 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.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.3