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

Q1776 Is it possible to make a pop-up window automatically resize to fit all the text and images contained in a page?

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

This works in IE. Encapsulate all the content of the document in a div. Set 2 event handlers in the body tag one for onLoad and one for onResize to fire the function fitWin(). This function gets the rendered height of the layer and the height of the window and resizes by the difference.

<script language="javascript"><!--
function fitWin(layer) {
  var targetH = layer.clientHeight;
  var outerH = document.body.clientHeight;
  var diff = outerH - targetH
  self.resizeBy(0,-diff);
}
//--></script>

<body onLoad="fitWin(holder)" onResize="fitWin(holder)">

<div id="holder" style="position:absolute; left:0px; top:0px; width:100%; height:100px; z-index:1">
<!-- content goes here -->
</div>

Submitted by Dave Whiting

©2018 Martin Webb