Window.resizeTo

« Window

Summary

Dynamically resizes window.

Syntax

window.resizeTo(aWidth, aHeight) 

Parameters

  • aWidth is an integer representing the new outerWidth in pixels (including scroll bars, title bars, etc).
  • aHeight is an integer value representing the new outerHeight in pixels (including scroll bars, title bars, etc).

Example

// function resizes the window to take up one quarter
// of the available screen.
function quarter() {
  window.resizeTo(
    window.screen.availWidth / 2,
    window.screen.availHeight / 2
  );
}

Notes

Since Firefox 7, it's no longer possible for a web site to change the default size of a window in a browser, according to the following rules:

  1. You can't resize a window or tab that wasn’t created by window.open.
  2. You can't resize a window or tab when it’s in a window with more than one tab.

See also window.resizeBy.

Specification

DOM Level 0. Not part of any standard.

Document Tags and Contributors

Last updated by: teoli,
Hide Sidebar