472,127 Members | 2,005 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,127 software developers and data experts.

Cross browser compatibility using offsetWidth

I know there are a lot of articles out there about this subject but I
have been reading for 3 hours and still can't find the answer. I have
some text in a bunch of hidden spans. I need to find the width in
pixels of that text. Using offsetWidth gives me a different value when
viewed in IE and Firefox. I need those to sync up somehow. I have tried
innerWidth, clientWidth, scrollWidth, etc. Any ideas?

Thanks in advance!

Jul 23 '05 #1
1 2897


pa******@hotmail.com wrote:
I know there are a lot of articles out there about this subject but I
have been reading for 3 hours and still can't find the answer. I have
some text in a bunch of hidden spans. I need to find the width in
pixels of that text. Using offsetWidth gives me a different value when
viewed in IE and Firefox.


Why not, browsers can have different defaults for font-family and
font-size, padding, margin, the browser windows can have different
dimenisions. In one browser window element.offsetWidth should give you
the correct pixel width for that element but don't expect to get the
same value in another browser window.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Simba | last post: by
17 posts views Thread by Mark Rae | last post: by
2 posts views Thread by Lüpher Cypher | last post: by
15 posts views Thread by CMM | last post: by
2 posts views Thread by cooldudevamsee | last post: by

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.