Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q1614 How can I offer the user the ability to resize the browser to 800x600, and then automatically resize to their original specification when they leave the page?

You are here: irt.org | FAQ | JavaScript | Window | Q1614 [ previous next ]

Try:

<html>

<head>
<title>offer resize</title>

<script language="JavaScript"><!--
var orgw, orgh = 0;
var resized = false;

function getXY() {
  if (document.body && document.body.clientWidth) {
    orgw = document.body.clientWidth;
    orgh = document.body.clientHeight;
  }
  else if (window.outerWidth) {
    orgw = window.outerWidth;
    orgh = window.outerHeight;
  }
}

function setXY() {
  if (resized) top.resizeTo(orgw,orgh);
}

function resize(x, y) {
alert(orgw + ' ' + orgh);
  resized = true;
  top.resizeTo(x, y);
  return false;
}
//--></script>

<body onLoad="getXY()" onUnload="setXY()">

<a href="javascript:;" onClick="return resize(800,600)">800x600</a>

</body>

</html>

©2018 Martin Webb