Javascript Browser Window resizeTo() Method compare to resizeBy()

Introduction

Using the resizeTo() method together with resizeBy():

Open a new window, and resize the width and height of the new window.

View in separate window

<!DOCTYPE html>
<html>
<body>

<button onclick="openWin()">Create window</button>
<button onclick="resizeWinTo()">Resize the window to 800px * 600px</button>
<button onclick="resizeWinBy()">Make the new window smaller</button>

<script>
var myWindow;//  w w  w .j  a  va2  s  . c om

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

function resizeWinTo() {
  myWindow.resizeTo(800, 600);
  myWindow.focus();
}

function resizeWinBy() {
  myWindow.resizeBy(-100, -50);
  myWindow.focus();
}
</script>

</body>
</html>



PreviousNext

Related