Web/API/Window/resizeBy

From Get docs


The Window.resizeBy() method resizes the current window by a specified amount.

Syntax

window.resizeBy(xDelta, yDelta) 

Parameters

  • xDelta is the number of pixels to grow the window horizontally.
  • yDelta is the number of pixels to grow the window vertically.

Example

// 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().

Creating and resizing an external window

 

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 compatability 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("http://myurl.domain", "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 orgin as the current window, you will not be able to resize, or access any information on, that window/tab.

Specifications

Specification Status Comment
CSS Object Model (CSSOM) View ModuleThe definition of 'window.resizeBy()' in that specification. Working Draft  

Browser compatibility

Update compatibility data on GitHub

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
resizeBy Chrome

Full support 1

Edge

Full support 12

Firefox Full support 1

Notes'

Full support 1

Notes'

Notes' Since 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 by window.open or contains more than one tab. See here for more details.

IE

Full support 4

Opera

Full support ≤12.1

Safari

Full support 1

WebView Android

Full support 1

Chrome Android

Full support 18

Firefox Android

Full support 4

Opera Android

Full support ≤12.1

Safari iOS

Full support 1

Samsung Internet Android

Full support 1.0

Legend

Full support  
Full support
See implementation notes.'
See implementation notes.