Window resizeTo() Method - Javascript Browser Object Model

Javascript examples for Browser Object Model:Window resizeTo

Description

The resizeTo() method resizes a window to the specified width and height.

Parameter Values

Parameter Type Description
width Number Required. Sets the width of the window, in pixels
heightNumber Required. Sets the height of the window, in pixels

Return Value:

No return value

The following code shows how to Open a new window, and set its width and height to 250px:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<button onclick="openWin()">Create window</button>
<button onclick="resizeWin()">Resize window</button>

<script>
var myWindow;//from  w w  w .j  a  va 2 s  .c  o  m

function openWin() {
    myWindow = window.open("", "", "width=100, height=100");
}

function resizeWin() {
    myWindow.resizeTo(250, 250);
    myWindow.focus();
}
</script>

</body>
</html>

Related Tutorials