In my stylesheet, I have set the height of a div and in Javascript, I want to be able to reference that height to properly position the div in the center of the browser. var divHeight =document.getElementById("modal_window").offsetHeight; Code (markup): That is the piece of Javascript I have been using, but can't seem to get it to work. Using the alert() function, it returns an integer of 0, even though the height is set in CSS. Any ways to fix this problem and find the height of a div using Javascript?
That would negate the purpose of using an external stylesheet. Inline styling just makes HTML look messy. I figured it out though....since display:none was set on the DIV, it wasn't being rendered with the webpage. Since it wasn't being rendered, it had no height value. I just switched the order of how my Javascript was read and wa la!