IE6 javascript can't get height by document.getElementById(id).offsetHeight
I just got a problem which is I can't get the height property of a <p>
.(use javascript document.getElementById(id).offsetHeight)
It works fine both in FF or chrome.
I have tried to set the style of the <p>
to height:100%;/heigh开发者_运维技巧t:auto;
but both not work.
Please help me, thanks :D
UPDATE: It seems that IE6 didn't return the offsetHeight value when page is loading, so maybe I have to put the javascript in the onload event? (Cause I put the javascript in the html during the page is load before).
Try document.getElementById(id).style.pixelHeight
(elm.style.pixelHeight/Width
is an IE-only property.) I've found sometimes it works but not offsetHeight
for some reason.
See also http://msdn.microsoft.com/en-us/library/ms531127(VS.85).aspx
It may also pay to add a "zoom: 1" to the element's style to trigger hasLayout
, which can sometimes fix finding the height if I recall correctly.
The answer is IE6 didn't return the offsetHeight value when page is loading, so I have to put the javascript in the body onload value.
It works.
Thanks for all the replies.
精彩评论