resize div overlay

how to resize div overlay, so it detects the size of main window (browser) and determine or set the position of overlay either goes up or down.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Pravin AsarPrincipal Systems EngineerCommented:
Here is a comprehensive example, which anchors the div to top , bottom and adjusts the middle one accordingly
based on the window size.

The Page listens to  onload and onresize events

<title>Set Height of Div on page load and resize-Pravin Asar</title>
<script language="javascript">
function GetWindowSize()
    this.width = 0;
    this.height =0;
    var myWidth=800;
    var myHeight=600;
	if( typeof( window.innerWidth ) == 'number' ) {
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	//IE 6+ in 'standards compliant mode'
	else if( document.documentElement &&
		  (document.documentElement.clientWidth || 
           document.documentElement.clientHeight )) {
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	//IE 4 compatible
	else if( document.body && 
             ( document.body.clientWidth || document.body.clientHeight ) ) {
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
    this.width = myWidth;
    this.height = myHeight;
    return (this);
function GetScreenSize () {
	this.width = window.screen.width;
	this.height = window.screen.height;
function setDivHeight () {
var ws = new GetWindowSize();
var ss = new GetScreenSize();
var hHt = 100;
var fHt = 50;
var dObj;
dObj = document.getElementById ('header'); = ws.width; = hHt;
dObj = document.getElementById ('content'); = ws.width; = ws.height - (hHt) - (fHt);
dObj = document.getElementById ('footer'); = ws.width; = (fHt);
<body onload="setDivHeight();" onresize="setDivHeight();">
<style type="text/css">
* {margin: 0px;
padding: 0px;
<div style="background-color: #FF9933;" id="header">HEADER</div>
<div style="background-color: #33DD99;" id="content">CONTENT</div>
<div style="background-color: #4499dd;" id="footer">FOOTER</div>

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.