innerHeight not calculating properly

I am using the following code to resize a div layer to the inner dimensions of the browser, the width works fine but the height is calculating at 133px, no matter what the resolution.  Any suggestions?
<style type="text/css">
#surveydiv
{
      position:absolute;
      top:0;
      left:0;
      background-color: #CC0033;
      border: solid 2px black;
      z-index: 10;

}
</style>
<div id="surveydiv">
</div>
<script type="text/javascript">
      var ns=(document.layers);
      var ie=(document.all);
      var w3=(document.getElementById && !ie);
function sizesurvey()
{
      if(ie)            adDiv=eval('document.all.surveydiv.style');
      else if(ns)      adDiv=eval('document.layers["surveydiv"]');
      else if(w3)      adDiv=eval('document.getElementById("surveydiv").style');
      if (ie){documentWidth=document.body.offsetWidth-4;
      documentHeight=document.body.offsetHeight;}      
      else if (ns){documentWidth=window.innerWidth;
      documentHeight=window.innerHeight;}
      else if (w3){documentWidth=self.innerWidth;
      documentHeight=self.innerHeight;}
      
      adDiv.width = documentWidth;
      adDiv.height = documentHeight;
      alert(documentHeight);
}
</script>
earthman100Asked:
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.

ZvonkoSystems architectCommented:
Change the div to this:

<div id="surveydiv">&nbsp;</div>

0
earthman100Author Commented:
I have entered content in the div and the height still does not change.
0
ZvonkoSystems architectCommented:
In Mozilla you have to add <body>

<style type="text/css">
#surveydiv
{
     position:absolute;
     top:0;
     left:0;
     background-color: #CC0033;
     border: solid 2px black;
     z-index: 10;

}
</style>
<body><div id="surveydiv"></body>
&nbsp;</div>
<script type="text/javascript">
     var ns=(document.layers);
     var ie=(document.all);
     var w3=(document.getElementById && !ie);
function sizesurvey()
{
     if(w3)          adDiv=eval('document.getElementById("surveydiv").style');
     else if(ns)     adDiv=eval('document.layers["surveydiv"]');
     else if(ie)     adDiv=eval('document.all.surveydiv.style');

     if (w3){documentWidth=self.innerWidth;
             documentHeight=self.innerHeight;}
     else if (ns){documentWidth=window.innerWidth;
                  documentHeight=window.innerHeight;}
     else if (ie){documentWidth=document.body.offsetWidth-4;
                  documentHeight=document.body.offsetHeight;}    

     adDiv.width = documentWidth;
     adDiv.height = documentHeight;
     alert(documentHeight);
}

sizesurvey()
</script>


0

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
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

ZvonkoSystems architectCommented:
Sorry, body was messed, but it worked then.
0
ZvonkoSystems architectCommented:
With <body> it works also like this:

<body><div id="surveydiv"></div></body>

0
GwynforWebCommented:
<script>
function sizesurvey(){
 documentHeight=(window.innerHeight || self.innerHeight || document.body.offsetHeight)
 documentWidth=(window.innerWidth || self.innerWidth || document.body.offsetWidth)
 alert(documentHeight+' '+documentWidth)
}
</script>

<body onload="sizesurvey()">

</body>
0
COBOLdinosaurCommented:
You are setting a style attribute.  For standards compliant browsers (which use innerHeight) you have to include the unit of measure.  Width defaults to 100% for a block element anyway so it is only height that is a problem.  Make the code standards compliant by changing

    adDiv.height = documentHeight;
to
    adDiv.height = documentHeight+'px';

Cd&
0
GwynforWebCommented:
eg

<script>
function sizesurvey(){
 documentHeight=(window.innerHeight || self.innerHeight || document.body.offsetHeight-50)
 documentWidth=(window.innerWidth || self.innerWidth || document.body.offsetWidth-50)
 document.getElementById('d1').style.height=documentHeight
 document.getElementById('d1').style.width=documentWidth
}
</script>

<body>
 <div id="d1" style="background:yellow;height:200;width:400">
   <input type="button" value="Adjust Div" onclick="sizesurvey()">
 </div>
</body>
0
ZvonkoSystems architectCommented:
Hello earthman100,
you have 10 questions still open.
Do you need more support in this particular question?
0
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
JavaScript

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.