Compatibility problems with offsetParent and offsetWidth

Discussion in 'Javascript' started by Ned Baldessin, Mar 2, 2005.

  1. Hi,

    I have reimplemented the non-standard <marquee> element (in a very
    simplified fashion), moving around a DIV using offsetParent and
    offsetWidth.
    It works fine in Mozilla (1.7.5) and Safari (1.2.4), but fails
    miserably in IE6/Win : the content scrolls off screen to the right hand
    side, although it should be going to the left.

    I've put up a simplified test case here :
    http://ned.idsland.com/2005/marquee.html

    Any suggestions ?

    Thanks.
    Ned Baldessin, Mar 2, 2005
    #1
    1. Advertising

  2. Ned Baldessin

    RobG Guest

    Ned Baldessin wrote:
    > Hi,
    >
    > I have reimplemented the non-standard <marquee> element (in a very
    > simplified fashion), moving around a DIV using offsetParent and
    > offsetWidth.
    > It works fine in Mozilla (1.7.5) and Safari (1.2.4), but fails miserably
    > in IE6/Win : the content scrolls off screen to the right hand side,
    > although it should be going to the left.
    >
    > I've put up a simplified test case here :
    > http://ned.idsland.com/2005/marquee.html
    >
    > Any suggestions ?
    >
    > Thanks.
    >


    Add "position: relative;" to the marquee class.

    You can ditch the 'parseInt' stuff too:

    s.style.left = (posS-posM-2) + 'px';

    You could use:

    s.style.left = posS-posM-2 + 'px';

    but I think that's less readable. Subtraction forces the
    variables to be numbers, parseInt has certain characteristics
    best avoided altogether if not needed.


    --
    Rob
    RobG, Mar 3, 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. Vittore Zen

    div - position - offsetParent

    Vittore Zen, Nov 4, 2004, in forum: Javascript
    Replies:
    1
    Views:
    118
    Martin Honnen
    Nov 4, 2004
  2. Replies:
    3
    Views:
    213
    Fred Oz
    Jan 13, 2005
  3. Replies:
    1
    Views:
    135
    Martin Honnen
    May 16, 2005
  4. Carlos
    Replies:
    0
    Views:
    219
    Carlos
    Feb 21, 2008
  5. Fabian Lenzen

    offsetParent and XUL/SVG

    Fabian Lenzen, May 16, 2008, in forum: Javascript
    Replies:
    1
    Views:
    113
    Andreas M.
    Jun 3, 2008
Loading...

Share This Page