Currently, I am attempting to find a solution on how to adjust column widths and heights using JavaScript so that they can be set based on the browser window size. I have tried the code below, but it does not seem to be working as expected. Any assistance would be greatly appreciated.
<script type="javascript">
function size()
{
document.getElementById("body").style.width = window.innerWidth;
document.getElementById("body").style.height = window.innerHeight;
var width = document.getElementById("body").style.width;
var height = document.getElementById("body").style.height;
document.getElementById("header").style.height = (.15 * height);
document.getElementById("loginbox").style.height = (.15 * height);
document.getElementById("navigation").style.height = (.05 * height);
document.getElementById("leftpanel").style.height = (.70 * height);
document.getElementById("contentarea").style.height = (.75 * height);
document.getElementById("addcolumn").style.height = (.75 * height);
document.getElementById("footer").style.height = (.10 * height);
document.getElementById("header").style.width = (.75 * width);
document.getElementById("loginbox").style.width = (.25 * width);
document.getElementById("navigation").style.width = width;
document.getElementById("leftpanel").style.width = (.20 * width);
document.getElementById("contentare").style.width = (.65 * width);
document.getElementById("addcolumn").style.width = (.15 * width);
document.getElementById("footer").style.width = width;
}
</script>
I utilize CSS to properly align the columns based on requirements, and then call the function `size()` within the body tag ( onload=size() ). However, the output is not as expected.
If anyone could offer guidance or solutions, I would be grateful!