offset top calculation problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Michael Hill

    offset top calculation problem

    If I have a button defined as:
    <input type="button" name="zzz">

    I can determine the top position using the function getOffsetTop below
    like:
    var tableTop = getOffsetTop(zz zz); //and I get a valid
    value

    However if I have another function involved where the button name is
    being passed to it I'm having a problem not knowing how to call this.

    onclick=temp(zz zz);

    function temp(mybutton)
    {
    var tableTop = getOffsetTop(my button);
    }

    function getOffsetTop (el)
    {
    var ot = el.offsetTop;
    while ( ( el = el.offsetParent ) != null )
    {
    ot += el.offsetTop;
    }
    return ot;
    }

  • Michael Hill

    #2
    Re: offset top calculation problem

    I'm sorry I didn't mean a button, I meant a link

    Michael Hill wrote:
    [color=blue]
    > If I have a button defined as:
    > <input type="button" name="zzz">[/color]

    should have been:

    <a href="javascrip t:some_script() ;" id="zzz"><img
    src="image_here "></a>
    [color=blue]
    >
    >
    > I can determine the top position using the function getOffsetTop below
    > like:
    > var tableTop = getOffsetTop(zz zz); //and I get a valid
    > value
    >
    > However if I have another function involved where the button name is
    > being passed to it I'm having a problem not knowing how to call this.
    >
    > onclick=temp(zz zz);
    >
    > function temp(mybutton)
    > {
    > var tableTop = getOffsetTop(my button);
    > }
    >
    > function getOffsetTop (el)
    > {
    > var ot = el.offsetTop;
    > while ( ( el = el.offsetParent ) != null )
    > {
    > ot += el.offsetTop;
    > }
    > return ot;
    > }[/color]

    Comment

    Working...