Connecting Tech Pros Worldwide Forums | Help | Site Map

offsetHeight not working in Firefox

Newbie
 
Join Date: Jun 2009
Location: Kathmandu, Nepal
Posts: 12
#1: Jul 1 '09
offsetHeight is not working in following code

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2. function Coverdiv()
  3. {
  4.     var standard=(document.compatMode=="CSS1Compat") ? document.documentElement:document.body;
  5.     var dv = document.createElement("div");
  6.     dv.setAttribute("id","cover");
  7.     document.body.appendChild(dv);
  8.     var cover=document.getElementById("cover");
  9.     //dv.innerHTML="Samit";
  10.     cover.style.top=0+"%";
  11.     cover.style.left=0+"%";
  12.     cover.style.backgroundColor="#000000";
  13.     cover.style.zIndex=100;
  14.     cover.style.height=100+"%";
  15.     cover.style.position="absolute";
  16.  
  17.     cover.style.width=100+"%";
  18.     cover.style.height=document.body.offsetHeight;
  19.     cover.style.opacity="0.8";
  20.  
  21.     var contDiv=document.createElement("div");
  22.     contDiv.setAttribute("id","Contents");
  23.     document.body.appendChild(contDiv);
  24.     var Content=document.getElementById("Contents");
  25.  
  26.     Content.innerHTML="Samit";
  27.     Content.style.top=50+"%";
  28.     Content.style.left=50+"%";
  29.     Content.style.backgroundColor="#FFFFFF";
  30.     Content.style.zIndex=101;
  31.     Content.style.height=20+"%";
  32.     Content.style.width=20+"%"
  33.     Content.style.position="absolute";
  34. };
  35. window.onload=Coverdiv;
  36. </script>

acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#2: Jul 1 '09

re: offsetHeight not working in Firefox


What do you expect it to be and what is it instead? Perhaps you should be using the greater of scrollHeight/offsetHeight.
Reply