View Single Post
  #4 (permalink)  
Old September 7th, 2003, 12:40 PM
Imar's Avatar
Imar Imar is offline
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Yeah, I thought about using currentStyle too, but it returns "auto" :-(

The offsetWidth, however, does the trick:
Code:
alert(document.getElementById('spTest').offsetWidth);
returns 87 which is indeed the exact size of the text in the <span> tag. Notice that offsetWidth is used directly on the object, not on the style property as in my example.....

Nice!


Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.