Open a new window, and resize it to 300 x 300:
function openWin() {
myWindow = window.open("", "", "width=200, height=100");
}
function resizeWin() {
myWindow.resizeTo(300, 300);
}
Try it Yourself »
More examples below.
The resizeTo()
method resizes a window to a new width and height.
window.resizeTo(
width, height)
Parameter | Description |
width | Required. The new window width, in pixels |
height | Required. The new window height, in pixels |
NONE |
Using resizeTo() with resizeBy():
function resizeWinTo() {
myWindow.resizeTo(800, 600);
}
function resizeWinBy() {
myWindow.resizeBy(-100, -50);
}
Try it Yourself »
resizeTo()
is supported in all browsers:
Chrome | Edge | Firefox | Safari | Opera | IE |
Yes | Yes | Yes | Yes | Yes | Yes |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!