Connecting Tech Pros Worldwide Help | Site Map

Safari offsetParent/offsetLeft Problem!

ara.pehlivanian@gmail.com
Guest
 
Posts: n/a
#1: Jul 23 '05
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

Martin Honnen
Guest
 
Posts: n/a
#2: Jul 23 '05

re: Safari offsetParent/offsetLeft Problem!




ara.pehlivanian@gmail.com wrote:
[color=blue]
> 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.[/color]

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.


--

Martin Honnen
http://JavaScript.FAQTs.com/
ara.pehlivanian@gmail.com
Guest
 
Posts: n/a
#3: Jul 23 '05

re: Safari offsetParent/offsetLeft Problem!


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

Fred Oz
Guest
 
Posts: n/a
#4: Jul 23 '05

re: Safari offsetParent/offsetLeft Problem!


ara.pehlivanian@gmail.com wrote:[color=blue]
> 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. :-([/color]

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.

--
Fred
Closed Thread