Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > calculated width of span element.

Reply
Thread Tools

calculated width of span element.

 
 
Erwin Moller
Guest
Posts: n/a
 
      09-05-2007
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
 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      09-05-2007
Erwin Moller wrote:

> Can I retrieve the used width of a span element via javascript?


Try whether
spanElement.offsetWidth
gives you the width you are looking for:
<URL:http://msdn2.microsoft.com/en-us/library/ms534304.aspx>




--

Martin Honnen
http://JavaScript.FAQTs.com/
 
Reply With Quote
 
 
 
 
Erwin Moller
Guest
Posts: n/a
 
      09-05-2007
Johannes Baagoe wrote:
> 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...nt.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
 
Reply With Quote
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      09-05-2007
Erwin Moller wrote:
> 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?


142% of all Web statistics are flawed.


HTH

PointedEars
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f806at$ail$1$(E-Mail Removed)>
 
Reply With Quote
 
Erwin Moller
Guest
Posts: n/a
 
      09-06-2007
Thomas 'PointedEars' Lahn wrote:
> Erwin Moller wrote:
>> 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?

>


> 142% of all Web statistics are flawed.


LOL.
Nothing beats a good laugh at the start of the workingday.
Thanks.

Erwin
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
I'm looking for html cleaner. Example : convert <h1><span><font>my title</font></span></h1> => <h1>my title</h1>… Stéphane Klein Python 2 03-30-2010 12:35 AM
Re: I'm looking for html cleaner. Example : convert <h1><span><font>my title</font></span></h1> => <h1>my title</h1>… Stefan Behnel Python 0 03-29-2010 08:14 PM
Can span include span? Fulio Open HTML 5 06-26-2009 10:24 PM
Textbox width scaling to width of data not width of page? AndrewF ASP .Net 1 10-10-2005 04:38 PM
DataGrid (body only) contained in <span>...</span> tags Dan Bishop ASP .Net Datagrid Control 2 06-07-2004 04:00 PM



Advertisments