bubbisthedog
10-17-2005, 10:36 AM
Hello,
I've been searching around for a while, and can not figure out how to adjust a relatively-positioned div height based on the browser height. I can get the screen height easily with JavaScript, but can't figure out how to apply it to the div height. Below is what I've been trying, but nothing happens. My setup is dead-simple: top div-750px width, 100px height; middle div (the one in question)-750px width, height dynamic; bottom div-750px width, 100px height.
<script>
<head>
window.onresize = divheight;
function divheight()
{
var hght = document.getElementById('results');
var adjwidth = 0, adjheight = 0;
if( typeof( window.innerWidth ) == 'number' )
{
//Non-IE
myHeight = window.innerHeight;
}
else if( document.documentElement &&
( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
{
//IE 6+ in 'standards compliant mode'
myWidth = document.documentElement.clientWidth;
myHeight = document.documentElement.clientHeight;
}
else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
{
//IE 4 compatible
myWidth = document.body.clientWidth;
myHeight = document.body.clientHeight;
}
set hght.height = myHeight - 200;
}
}
</script>
</head>
Could someone please tell me where I'm going wrong here? As you can probably tell, I'm still learning how to apply JavaScript. I'd really appreciate any assistance with this issue.
Regards,
bubbis
I've been searching around for a while, and can not figure out how to adjust a relatively-positioned div height based on the browser height. I can get the screen height easily with JavaScript, but can't figure out how to apply it to the div height. Below is what I've been trying, but nothing happens. My setup is dead-simple: top div-750px width, 100px height; middle div (the one in question)-750px width, height dynamic; bottom div-750px width, 100px height.
<script>
<head>
window.onresize = divheight;
function divheight()
{
var hght = document.getElementById('results');
var adjwidth = 0, adjheight = 0;
if( typeof( window.innerWidth ) == 'number' )
{
//Non-IE
myHeight = window.innerHeight;
}
else if( document.documentElement &&
( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
{
//IE 6+ in 'standards compliant mode'
myWidth = document.documentElement.clientWidth;
myHeight = document.documentElement.clientHeight;
}
else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
{
//IE 4 compatible
myWidth = document.body.clientWidth;
myHeight = document.body.clientHeight;
}
set hght.height = myHeight - 200;
}
}
</script>
</head>
Could someone please tell me where I'm going wrong here? As you can probably tell, I'm still learning how to apply JavaScript. I'd really appreciate any assistance with this issue.
Regards,
bubbis