offsetHeight not working in Firefox

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bob2044
    New Member
    • Jun 2009
    • 16

    offsetHeight not working in Firefox

    offsetHeight is not working in following code

    Code:
    <script type="text/javascript">
    function Coverdiv()
    {
    	var standard=(document.compatMode=="CSS1Compat") ? document.documentElement:document.body;
    	var dv = document.createElement("div");
    	dv.setAttribute("id","cover");
    	document.body.appendChild(dv);
    	var cover=document.getElementById("cover");
    	//dv.innerHTML="Samit";
    	cover.style.top=0+"%";
    	cover.style.left=0+"%";
    	cover.style.backgroundColor="#000000";
    	cover.style.zIndex=100;
    	cover.style.height=100+"%";
    	cover.style.position="absolute";
    	
    	cover.style.width=100+"%";
    	cover.style.height=document.body.offsetHeight;
    	cover.style.opacity="0.8";
    	
    	var contDiv=document.createElement("div");
    	contDiv.setAttribute("id","Contents");
    	document.body.appendChild(contDiv);
    	var Content=document.getElementById("Contents");
    	
    	Content.innerHTML="Samit";
    	Content.style.top=50+"%";
    	Content.style.left=50+"%";
    	Content.style.backgroundColor="#FFFFFF";
    	Content.style.zIndex=101;
    	Content.style.height=20+"%";
    	Content.style.width=20+"%"
    	Content.style.position="absolute";
    };
    window.onload=Coverdiv;
    </script>
    Last edited by Dormilich; Jul 1 '09, 01:25 PM. Reason: added [code] tags
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

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

    Comment

    Working...