Cross browser compatibility using offsetWidth

P

parksch2

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!
 
M

Martin Honnen

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.
 

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

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top