Window.resizeTo()
Summary
Dynamically resizes window.
Syntax
JavaScript
Copy Code
window.resizeTo(aWidth, aHeight)
Parameters
aWidth
is an integer representing the newouterWidth
in pixels (including scroll bars, title bars, etc).aHeight
is an integer value representing the newouterHeight
in pixels (including scroll bars, title bars, etc).
Example
JavaScript
Copy Code
// 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:
- You can't resize a window or tab that wasn’t created by window.open.
- You can't resize a window or tab when it’s in a window with more than one tab.
See also window.resizeBy
.
Specification
Specification | Status | Comment |
---|---|---|
CSS Object Model (CSSOM) View Module The definition of 'window.resizeTo()' in that specification. |
Working Draft |
License
© 2016 Mozilla Contributors
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-us/docs/web/api/window/resizeto