offsetTop是指当前单元格与表顶部的距离.下面的代码试试就知道了.
<table cellpadding="0" cellspacing="0" border="1" style="POSITION: absolute; top:120; left:500; height: 90;">
<tr>
<td>dfdf</td>
</tr>
<tr>
<td>dfdf</td>
</tr>
<tr>
<td onclick="alert(this.offsetTop)">dfdf</td>
</tr>
</table>
<table cellpadding="0" cellspacing="0" border="1" style="POSITION: absolute; top:120; left:500; height: 90;">
<tr>
<td>dfdf</td>
</tr>
<tr>
<td>dfdf</td>
</tr>
<tr>
<td onclick="alert(this.offsetTop)">dfdf</td>
</tr>
</table>
alert(this.offsetTop+this.clientHeigh)
alert(this.clientHeigh)就可以了.
x=oRect.left;
y=oRect.top+main.scrollTop;用这个绝对定位,main.scrollTop获取Body滚动的距离,这样就很精确了
Retrieves the calculated top position of the Tag relative to the layout or coordinate parent, as specified by the offsetParent property.
-------
即:offset是相对于它的offsetParent来的,并不是相对body的位置,
<table cellpadding="0" cellspacing="0" border="1" style="POSITION: absolute;top:100;left:100">
<tr>
<td>dfdf</td>
</tr>
<tr>
<td onclick="alert(this.offsetTop+this.offsetParent.offsetTop)">dfdf</td>
</tr>
</table>