Safari offsetParent/offsetLeft Problem!

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ara.pehlivanian@gmail.com

    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

  • Martin Honnen

    #2
    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

    Comment

    • ara.pehlivanian@gmail.com

      #3
      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

      Comment

      • Fred Oz

        #4
        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.h tml>

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

        --
        Fred

        Comment

        Working...