Cross browser compatibility using offsetWidth

Discussion in 'Javascript' started by parksch2@hotmail.com, May 15, 2005.

  1. Guest

    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!
    , May 15, 2005
    #1
    1. Advertising

  2. 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/
    Martin Honnen, May 16, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    7
    Views:
    11,898
    Juan T. Llibre
    Mar 15, 2006
  2. =?Utf-8?B?cHJvZl9tYXJ0aW4=?=

    Cross-browser compatibility of Asp.net v.1.1 & 2.0

    =?Utf-8?B?cHJvZl9tYXJ0aW4=?=, Apr 25, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    3,584
    Juan T. Llibre
    Apr 25, 2006
  3. jb
    Replies:
    16
    Views:
    704
    Toby A Inkster
    Dec 8, 2003
  4. Sally Thompson
    Replies:
    8
    Views:
    564
    Sally Thompson
    Jun 19, 2004
  5. Ned Baldessin
    Replies:
    1
    Views:
    177
Loading...

Share This Page