Jump to content

[SOLVED] element height


ldsmike88

Recommended Posts

Every time I try to set the heigth of a div equal to the height of the document it freezes up. How do I make this work? Thanks!

 

function MyWindowResized(){
var myWindowHeight = document.body.clientHeight;
document.getElementById('main').style.height = myWindowHeight + 'px';
}

Link to comment
https://forums.phpfreaks.com/topic/43417-solved-element-height/
Share on other sites

Fixed it! Apparently if you use 'body' it just gets the height of the document. If you use documentElement it gets the height of the window.

 

function windowResized(){
document.getElementById('main').style.height = document.documentElement.clientHeight - 50;
document.getElementById('side').style.height = document.documentElement.clientHeight - 50;

document.getElementById('main').style.width = document.body.clientWidth - 215;
document.getElementById('side').style.width = 200;
}

Link to comment
https://forums.phpfreaks.com/topic/43417-solved-element-height/#findComment-210900
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.