Link to home
Start Free TrialLog in
Avatar of earthman100
earthman100

asked on

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>
Avatar of Zvonko
Zvonko
Flag of North Macedonia image

Change the div to this:

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

Avatar of earthman100
earthman100

ASKER

I have entered content in the div and the height still does not change.
ASKER CERTIFIED SOLUTION
Avatar of Zvonko
Zvonko
Flag of North Macedonia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Sorry, body was messed, but it worked then.
With <body> it works also like this:

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

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hello earthman100,
you have 10 questions still open.
Do you need more support in this particular question?