Layer Positioning

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • unwantedspam@mchsi.com

    Layer Positioning

    Thank you in advance.
    I have a table with a <DIV> in it and would like to get the left
    property of the <DIV>. It comes back 0. I would like to get the the
    position relative to the screen (like 354). Is this possible? If so
    could you please point me in the right direction?

    Thanks

    <TABLE ALIGN="center">
    <TR>
    <TD>
    <DIV>Some Text</DIV>
    </TD>
    </TR>
    </TABLE>

  • Dylan Parry

    #2
    Re: Layer Positioning

    Pondering the eternal question of "Hobnobs or Rich Tea?",
    unwantedspam@mc hsi.com finally proclaimed:
    [color=blue]
    > I have a table with a <DIV> in it and would like to get the left
    > property of the <DIV>. It comes back 0. I would like to get the the
    > position relative to the screen (like 354). Is this possible? If so
    > could you please point me in the right direction?[/color]

    I found the following functions somewhere a while ago:

    /*
    Function to find the x position of the top left corner of
    a given object
    */
    function findPosX(obj) {
    var curleft = 0;
    if (obj.offsetPare nt) {
    while (obj.offsetPare nt) {
    curleft += obj.offsetLeft
    obj = obj.offsetParen t;
    }
    }
    else if (obj.x)
    curleft += obj.x;
    return curleft;
    }

    /*
    Function to find the y position of the top left corner of
    a given object
    */
    function findPosY(obj) {
    var curtop = 0;
    if (obj.offsetPare nt) {
    while (obj.offsetPare nt) {
    curtop += obj.offsetTop
    obj = obj.offsetParen t;
    }
    }
    else if (obj.y)
    curtop += obj.y;
    return curtop;
    }

    I'm sure they can be improved upon, but they've done the job for me on
    many occasions!

    --
    Dylan Parry
    http://webpageworkshop.co.uk -- FREE Web tutorials and references

    Comment

    Working...