The resizeTo()
method resizes a window to the specified width and height.
resizeTo |
Yes | Yes | Yes | Yes | Yes |
window.resizeTo(width,height)
Parameter | Description |
---|---|
width | Required. Sets the width in pixels |
height | Required. Sets the height in pixels |
No return value.
The following code shows how to open a new window, and resize the width and height to 250px.
<!DOCTYPE html>
<html>
<body>
<button onclick="openWin()">Create window</button>
<button onclick="resizeWin()">Resize window</button>
<!--from w w w .ja v a 2 s . c o m-->
<script>
var myWindow;
function openWin() {
myWindow = window.open("", "", "width=100, height=100");
}
function resizeWin() {
myWindow.resizeTo(250, 250);
myWindow.focus();
}
</script>
</body>
</html>
The code above is rendered as follows: