Entry
How can I size a window to its content's size? There is an answer to this question but not for IE.
Aug 16th, 2004 08:27
Russ Locke, Guest,
function autoResizeWindow() {
// get these values after the document has been fully opulated
var displayWidth = window.top.document.body.offsetWidth;
var actualWidth = document.body.scrollWidth;
var displayHeight = window.top.document.body.offsetHeight;
var actualHeight = document.body.scrollHeight;
var resize = false;
if (actualWidth > displayWidth) {
resize = true;
displayWidth = actualWidth;
}
if (actualHeight > displayHeight) {
resize = true;
displayHeight = actualHeight+25; // +25 for the title bar
}
var widthOffset = 6;
var heightOffset = 6;
// make sure we do not resize bigger than the screen resolution
if (displayWidth+widthOffset > window.screen.width)
displayWidth = window.screen.width;
if (displayHeight+heightOffset > window.screen.height)
displayHeight = window.screen.height;
if (resize)
resizeTo(displayWidth+widthOffset, displayHeight+heightOffset);
}