Compatibility problems with offsetParent and offsetWidth

N

Ned Baldessin

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.
 
R

RobG

Ned said:
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.
 

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,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top