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.getElementByI d && !ie);
function sizesurvey()
{
if(ie) adDiv=eval('document.all.s urveydiv.s tyle');
else if(ns) adDiv=eval('document.layer s["surveyd iv"]');
else if(w3) adDiv=eval('document.getEl ementById( "surveydiv ").style') ;
if (ie){documentWidth=documen t.body.off setWidth-4 ;
documentHeight=document.bo dy.offsetH eight;}
else if (ns){documentWidth=window. innerWidth ;
documentHeight=window.inne rHeight;}
else if (w3){documentWidth=self.in nerWidth;
documentHeight=self.innerH eight;}
adDiv.width = documentWidth;
adDiv.height = documentHeight;
alert(documentHeight);
}
</script>
<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.getElementByI
function sizesurvey()
{
if(ie) adDiv=eval('document.all.s
else if(ns) adDiv=eval('document.layer
else if(w3) adDiv=eval('document.getEl
if (ie){documentWidth=documen
documentHeight=document.bo
else if (ns){documentWidth=window.
documentHeight=window.inne
else if (w3){documentWidth=self.in
documentHeight=self.innerH
adDiv.width = documentWidth;
adDiv.height = documentHeight;
alert(documentHeight);
}
</script>
ASKER
I have entered content in the div and the height still does not change.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Sorry, body was messed, but it worked then.
With <body> it works also like this:
<body><div id="surveydiv"></div></bod y>
<body><div id="surveydiv"></div></bod
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hello earthman100,
you have 10 questions still open.
Do you need more support in this particular question?
you have 10 questions still open.
Do you need more support in this particular question?
<div id="surveydiv"> </div