Connecting Tech Pros Worldwide Help | Site Map
 
 
LinkBack Thread Tools Search this Thread
  #1  
Old July 23rd, 2005, 05:33 PM
ara.pehlivanian@gmail.com
Guest
 
Posts: n/a
Default Safari offsetParent/offsetLeft Problem!

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

  #2  
Old July 23rd, 2005, 05:33 PM
Martin Honnen
Guest
 
Posts: n/a
Default 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/
  #3  
Old July 23rd, 2005, 05:34 PM
ara.pehlivanian@gmail.com
Guest
 
Posts: n/a
Default 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

  #4  
Old July 23rd, 2005, 05:34 PM
Fred Oz
Guest
 
Posts: n/a
Default 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
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 205,248 network members.