0

hi
i want to get height of a div with document.gtElementById('divid').offsetHeight in javascript. it works well in firefox but in IE it returns 0.
what is the solution?
i guess maybe the offsetHeight doesn't work in IE ,but
document.body.offsewtHeight
return a number bigger than 0 ! altought it is different from what firefox returns.

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by arunss
0
function findPosX(obj) {
    var curleft = 0;
    if (obj.offsetParent) {
        while (1) {
            curleft+=obj.offsetLeft;
            if (!obj.offsetParent) {
                break;
            }
            obj=obj.offsetParent;
        }
    } else if (obj.x) {

        curleft+=obj.x;
    }
    return curleft;
}
function findPosY(obj) {
    var curtop = 0;
    if (obj.offsetParent) {
        while (1) {
            curtop+=obj.offsetTop;
            if (!obj.offsetParent) {
                break;
            }
            obj=obj.offsetParent;
        }
    } else if (obj.y) {
        curtop+=obj.y;
    }
    return curtop;
}
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.