Safari offsetParent/offsetLeft Problem!

A

ara.pehlivanian

I've got a script that determines the true position of an element in
the page by cycling up the .offsetParent elements all the way up to the
<body> element and tallying up the .offsetLeft values returned by each
element. It works fine on the major browsers (IE, Moz, NS) on PC but
Safari on the Mac returns "0" for the offsetLeft right off the body tag
when it should be a greater value than that.
Anybody already deal with this?

Thank you in advance!
Ara
 
M

Martin Honnen

I've got a script that determines the true position of an element in
the page by cycling up the .offsetParent elements all the way up to the
<body> element and tallying up the .offsetLeft values returned by each
element. It works fine on the major browsers (IE, Moz, NS) on PC but
Safari on the Mac returns "0" for the offsetLeft right off the body tag
when it should be a greater value than that.

You should not stop at the <body> element but walk up offsetParent till
it is null. Perhaps with Safari the <html> element adds an offset. Just
a guess however, I haven't looked into that with Safari now.
 
A

ara.pehlivanian

Hi Martin,

Thanks for the reply. The thing is, I was using .parentNode to cycle
through all the elements but that was returning very strange results
since not all parent nodes affected the offset of their children.
However by using .offsetParent I was able to get only those who
affected the offset of their children. I say this because using the
..parentNode method, I was able to get all the way up past the <body>,
past <html> all the way to <#document>. But this way I can't.

Besides, I don't even think it would help since Safari reports the
offset differently than IE, Mozilla and NS using the same code. :-(

Ara
 
F

Fred Oz

Hi Martin,

Thanks for the reply. The thing is, I was using .parentNode to cycle
through all the elements but that was returning very strange results
since not all parent nodes affected the offset of their children.
However by using .offsetParent I was able to get only those who
affected the offset of their children. I say this because using the
..parentNode method, I was able to get all the way up past the <body>,
past <html> all the way to <#document>. But this way I can't.

Besides, I don't even think it would help since Safari reports the
offset differently than IE, Mozilla and NS using the same code. :-(

Have you had a look here?

<URL:http://www.quirksmode.org/index.html?/viewport/compatibility.html>

It's not specific to Safari, but it offers some good tips and hints.
 

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,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top