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 );
Printable View
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 );
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:you use:HTML Code:<body>
content goes here
</body>
You can use this handy piece of code:HTML Code:<body>
<div>
content goes here
</div>
</body>
Using:Code:var H = document.getElementsByTagName('div')[0].offsetHeight;
window.resizeTo( 220 , H );
should work but IE doesn't 'get it' unless you use at least a transitional doctype, Mozilla based browsers have no problem recognizing it.Code:document.getElementsByTagName('body')[0].offsetHeight;
Added Later:
You will still have to add about 150 to H to allow for the window's chrome.