Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

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

irt.org | Knowledge Base | category | subcategory | Q1776 [ previous next ]

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

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


Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.