PDA

View Full Version : IE, element.offsetHeight = 0!?



ItsMeOnly
11-27-2006, 03:53 PM
Hi

From http://www.gogolek.com I wanted to implement my "sliding content" script on http://www.id.uw.edu.pl/zajecia.htm?zajecia=.rie (click "Więcej o zajęciach" to observe effect), unfortunately- while in FF it works flawlessly, IE fails without error. I isolated problem to this one:

function grab() {
for (var i = 1; i <= 10; i++) {
sectObj = document.getElementById("sect" + i);

tmpHeight[i] = 0;
if (sectObj) {
absHeight[i] = sectObj.offsetHeight;
}

hideStep[i] = Math.round(100 / Math.round(absHeight[i] / 45));
showStep[i] = Math.round(100 / Math.round(absHeight[i] / 35));

tmpOpacity[i] = "100";
}
}

In this particular configuration sectObj.offsetHeight is always 0 in every iteration, I have no idea why is that (it works perfectly in www.gogolek.com, and I don't see any major difference in code or style). The wild workaround is to hardcode a value into absHeight[i], but I don't think it's elegant solution at all.

Referenced thread: http://www.dynamicdrive.com/forums/showthread.php?t=14670