473,472 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

calculated width of span element.

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
Sep 5 '07 #1
5 9668
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/
Sep 5 '07 #2
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)

--
Johannes
"Quand on dit c'est un Johannes, cela vaut autant que ce que maintenant
on appelle un pédant" (H. Estienne, cité dans le Littré, art. PÉDANT)
Sep 5 '07 #3
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
Sep 5 '07 #4
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, <f8*******************@news.demon.co.uk>
Sep 5 '07 #5
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. :P

Erwin
Sep 6 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Jeff Thies | last post by:
I have something like this: <span style="width:12ex; text-align: right">field label</span><input type="text" ...> (I suppose it may be better to do that with label. I'm not really sure what...
2
by: Kai Grossjohann | last post by:
I would like to put a text input field (in the sense of <input type="text">) and an image next to each other, where I know the size in pixels of the image, and I know the total width in em. I...
14
by: Florian Brucker | last post by:
Hi! Here's what it should look like: <style type="text/css"> span.h1 { border-style:solid; border-width:0px; border-color:#000000; border-bottom-width:2px;
6
by: bugbear | last post by:
I've spent the last 2 days reading in waaay too much detail the specs for CSS and HTML. I am attempting something very simple. I wish to wrap an image and caption in a span, so that the text can...
2
by: Showtime | last post by:
Hi! I have a text and I need to get its width in pixels. The font size is not fixed. I've been suggested to put the text inside of an invisible div and get the div's width. But I would need to...
1
by: mpayne | last post by:
I have a span that has a width of 25%. I want to use that span as the top of a dialog box that has rounded corners. So, the span itself is broken up into 3 smaller spans, one for the left and...
4
by: petermichaux | last post by:
Hi, I'm curious why the follow little HTML page produces "auto" for JavaScript output. I thought that getComputedStyle() was supposed to return integer px values for lengths. Is this a problem...
6
by: lilOlMe | last post by:
Hi there! I'm having a problem with a <span> element's width. I have a span element within a div block: <div class="picker"> <span id="ctl00_cph_mainContent_TPKR_Tues_LBL_TitleForPicker"...
5
by: Summercool | last post by:
wow... i didn't know that, for <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http:// www.w3.org/TR/html4/loose.dtd"> <span style="width: 100px; background:...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.