View Full Version : resizing

05-28-2005, 10:55 AM
Hi, I'm trying to dynamically resize a window's height based on the content, this it what I have, but it's not working.

var H=document.body.clientHeight;
window.resizeTo( 220 , H );

05-28-2005, 06:36 PM
That might work in IE on a page with no doctype, sort of. The expression 'clientHeight' is an IE proprietary one that measures the height of the window. So, on browsers that support it, you are measuring the current height of the window and then setting the height to it. If you wrap your page in a division tag, so instead of:

content goes here

</body>you use:

content goes here

</body>You can use this handy piece of code:
var H = document.getElementsByTagName('div')[0].offsetHeight;
window.resizeTo( 220 , H );Using:
document.getElementsByTagName('body')[0].offsetHeight;should work but IE doesn't 'get it' unless you use at least a transitional doctype, Mozilla based browsers have no problem recognizing it.

Added Later:

You will still have to add about 150 to H to allow for the window's chrome.