PDA

View Full Version : find the width in px, if CSS is %


Kor
11-20-2003, 08:41 AM
I try to find the width in px of an element_id. I used the read-only property document.getElementById(id).currentStyle.width, but as the CSS atribute is written in % I got the same % value...

I can use that value 'cose I always know the parent value from which that % value is percent of, but... Is there a direct DOM value for that?

I know that there is something like offsetParent property, but I didn' find out how to use it

glenngv
11-20-2003, 08:51 AM
try

document.getElementById(id).offsetWidth

Kor
11-20-2003, 09:07 AM
yeap, thanks, I forgot about offsetWidth.

Yet...as a curiosity...how can I use offsetParent?... It looks like
document.getElementById(id).offsetParent woun't work till I'll create the parent object... Or something like that...