Compatibility problems with offsetParent and offsetWidth

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ned Baldessin

    #1

    Compatibility problems with offsetParent and offsetWidth

    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 :


    Any suggestions ?

    Thanks.

  • RobG

    #2
    Re: Compatibility problems with offsetParent and offsetWidth

    Ned Baldessin wrote:[color=blue]
    > 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.
    >[/color]

    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

    Comment

    Working...