i'm writting a script and i want to know how to get the height of a div layer through javascript. I know i can get the height if the layer is using the style property like so html Code: <div id='blah' style='height:10px;'>... js Code: obj.style.height But i want to use classes, and i have not been able to figure it out. Html Code: <div id='blah' class='poo'>... I would really appreciate some help, i havent been able to find it on google. thx Jimmy
ok, to get the height, you want somthing like this: Code: height = document.getElementById('blah').style.height; i hope that javascript is right, if not, i'm sure someone will correct me and to use a class, you do this in your style sheet: Code: <style type="text/css"> .poo {attributes: here; } </style> remeber, classes use a period(.) in the style sheet, and ids use a pound sign(#). good luck! later
thanks for the reply, but everytime i've tried to get the height of the object when its using a class it returns undefined. When i dont use a class, and just do <div id='fsdf' style='height:blah;'>... it works fine. This is where i have the problem.
Properties of interest offsetHeight offsetWidth offsetTop offsetLeft clientWidth clientHeight scrollTop scrollLeft
i think you actually have to set the height like that (per tag basis) to get the height and width from js. not 100% sure on that. good luck on your stuff though man. maybe someone with more experience in what you are trying to do will have a solution for ya. sorry man. later
i figured out when setting it i can just use obj.style.height, and when getting it i can just use obj.offsetHeight
i've got one more problem, i tried to implement this script into my xhtml page and it doesnt let me set the obj.style.left property anymore. But if i make the page regular html it works, but my page looks f* up. Any suggestions?
For anyone who wants to know i figured out how to fix the problem when using xhtml i had to do NodeElementChild.style.left = Location[0]+"px"; instead of doing NodeElementChild.style.left = Location[0]; i was just sitting there switching things around and this worked.