By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,701 Members | 1,711 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,701 IT Pros & Developers. It's quick & easy.

offset top calculation problem

P: n/a
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(zzzz); //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(zzzz);

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

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

Jul 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
I'm sorry I didn't mean a button, I meant a link

Michael Hill wrote:
If I have a button defined as:
<input type="button" name="zzz">
should have been:

<a href="javascript:some_script();" id="zzz"><img
src="image_here"></a>


I can determine the top position using the function getOffsetTop below
like:
var tableTop = getOffsetTop(zzzz); //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(zzzz);

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

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


Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.