Firefox needs to get the height of the div, often need to use offsetheight, sometimes encounter offsetheight get to 0 of the phenomenon,
In the use of IE or Firefox, especially in the current div+css way, often do not define the height of Div, this is added div content, need to get the height of Div, often need to use the offsetheight.
In use, sometimes encounter offsetheight get to 0 of the phenomenon, but if you use a variety of JS Debugging Tools debugging, but also in the object to see the value (if the direct point to offsetheight is not worth, but if the object view is a value, The object is refreshed by a carriage return view in the debugger, so there is a value. )
Like the following fragments.
The code is as follows:
Copy Code code as follows:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html>
<head>
<script language= ' JavaScript ' >
window.attachevent ("onload", function () {_resizescroll2 ();});
window.onresize=function () {winresize ();};
function _resizescroll2 () {
var html1 = ' <div id= ' divcj ' style= ' margin-top:15px;font-size:10px;width:400px; > '
+ ' <div style= ' float:left;width:50px; > Test </div> '
+ ' <div style= ' float:left;width:320px; >danielinbiti</div> '
+ ' </div> '
+ ' <div id= ' divcj2 ' style= ' margin-top:15px;font-size:10px;width:400px; > '
+ ' <div style= ' width:320px; >danielinbiti</div> '
+ ' </div> '
document.getElementById (' outer '). INNERHTML=HTML1;
document.getElementById (' divcj2 '). style.display= ' None ';
Alert (document.getElementById (' divcj2 '). offsetheight);
}
</script>
</head>
<body>
<div id= ' outer ' ></div>
</body>
</html>
If you get the height of the DIVCJ, you get 0 in onload. Because the DIVCJ under the float way layout.
At this point if the div is simple, you can use the hidden layer, such as the divcj2 here, the float removed, get the height and divcj as high.
Here is a key point is that the float layout in IE is no problem, but for Firefox it takes 0