calculated width of span element.

E

Erwin Moller

Hi group,

Can I retrieve the used width of a span element via javascript?
If so how?
(I am fine with javascript, but my CSS knowledge leaves a lot to be
desired.)

I tried using width, but that only returns the value I use to create the
span, which is empty in my case.
I have a variable tekst in the span.
I googled around but cannot find the right search words.

Any suggestions?

TIA

Regards,
Erwin Moller
 
E

Erwin Moller

Johannes said:
Erwin Moller :
Can I retrieve the used width of a span element via javascript? [...] I
googled around but cannot find the right search words.
Any suggestions?

You could try "offsetWidth". Not in any official standard, but it might
still help. (http://developer.mozilla.org/en/docs/DOM:element.offsetWidth)

Thanks Martin and Johannes,

That unofficial property seem to work out just fine. :)
I actually needed 'left' too, but that was named (surprise suprise)
offsetLeft.

accordig to this list:
http://www.appcreator.com/dom-browser-support
it is supported by IE5 and above, FF2, and opera 6 and 7.
That is enough for me. :)
That should sum up ???... >99% of the webvisitors?

Thanks!

Regards,
Erwin Moller
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top