This page is Almost Ready

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

resizeTo

Summary

Sets the size of the window to the specified width and height values.

Method of dom/Windowdom/Window

Syntax

 window.resizeTo(/* see parameter list */);

Parameters

x

Data-type
Number

Integer that specifies the width of the window in pixels. The value can be either positive or negative.

y

Data-type
Number

Integer that specifies the height of the window in pixels. The value can be either positive or negative.

Return Value

No return value

Examples

// 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

Remarks

This method is not valid with windows created using the showModalDialog method. In order to move or resize a dialog window created with these methods, change the dialogHeight, dialogWidth, dialogTop, and dialogLeft properties. If the page (that contains this script) is hosted within an IFRAME, the IFRAME will move relative to the upper-left corner of the content area. Windows XP Service Pack 2 (SP2) or later. Windows that are located in the Internet Zone are subject to Window_Restrictions and will be forced to stay on screen. This applies to moveTo, moveBy, resizeTo, and resizeBy methods. Note: When operating in high-dpi mode, pixel values are scaled up accordingly. See Adjusting Scale for Higher DPI Screens for additional information. Windows Internet Explorer 7. This method is only effective when a single tab is open or when tabbed browsing is disabled. If multiple tabs are open, this method is blocked. For information regarding tab interaction from a script, see Tabbed Browsing for Developers. Internet Explorer 7. This method is blocked if called by a foreign domain within a sub-frame (FRAME/IFRAME).

Attributions