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.

Recommended Answers

All 2 Replies

the problem was something else !
it is solved now.

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;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.