<br>
<div id=t></div>
<script>
alert(document.all.t.style.pixelTop)
</script>

解决方案 »

  1.   

    <br>
    <div id=t></div>
    <script>
    alert(document.all.t.offsetTop)
    alert(document.all.t.clientTop)
    alert(document.all.t.style.posTop)
    </script>
      

  2.   

    看你的需求了,想得到什么样的top值默认的top是auto自动获取当前位置
    document.all.t.currentStyle.top如果是left把所有的Top改称Left
      

  3.   

    <div id=movingDiv class=movingDiv style="VISIBILITY: hidden; POSITION: absolute; z-index:100"><table width=80>aa</table></div> <div id="docID<%=rs("docID").Value%>" style="cursor:hand; "><%=strtitle%></div>movingDiv的top是335px,单位是像素;另一个div块:如docID5,取:document.all.docID5.offsetTop的单位不是像素。我想比较一下这两个div块的高度。
      

  4.   

    <p>测试<p>测试
    <div id=movingDiv class=movingDiv style="VISIBILITY: hidden; POSITION: absolute; z-index:100"><table width=80>aa</table></div> 
    <div id="docIDa" style="cursor:hand; ">ddddd</div>
    <input onclick="alert(movingDiv.offsetTop);alert(docIDa.offsetTop)" type=button value=" 测试 ">
      

  5.   

    这样两个div块的top不是比不出来了吗?都是64
      

  6.   

    去http://www.eb-star.net/tech/designxp/default.asp自己研究代码,可以把div在页面任意拖拽定位,并且可以记忆。
      

  7.   

    但实际上它也都在那个位置不过可以通过他们的zIndex来区分
      

  8.   

    是这样的:
    docID5放在表格td里面,
    movingDiv没有放在表格里面。
    使用docID5.offsetTop仅仅取得这个div块相对于它所在的td的top,
    不能和movingDiv.style.pixelTop相比。我说要做的是比较这两个div快的高度差,谁在上面,谁在下面。
      

  9.   

    <p>测试<p>测试
    <div id=movingDiv class=movingDiv style="VISIBILITY: hidden; POSITION: absolute; z-index:100"><table width=80>aa</table></div> 
    <table><td>
    <div id="docIDa" style="cursor:hand; ">ddddd</div></td></table>
    <input onclick="alert(getTop('docIDa'));alert(getTop('movingDiv'))" type=button value=" 测试 ">
    <script>
    function getTop(str){
    var e=document.all(str);
    var t=e.offsetTop;
    while(e=e.offsetParent)t+=e.offsetTop;
    return t;
    }
    </script>