Sorry!!
如何得到网页中的一个表格距离浏览器顶端的高度?
thks!

解决方案 »

  1.   

    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>无标题文档</title>
    <script language="Javascript">
    function getIE(e){
      var t=e.offsetTop;
      var l=e.offsetLeft;
      while(e=e.offsetParent){
        t+=e.offsetTop;
        l+=e.offsetLeft;
        }
      alert("top="+t+"\nleft="+l);
      }
    </script>
    </head><body>
    <table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td><table width="50%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#666666">
            <tr bgcolor="#A6AE8C"> 
              <td onClick="getIE(this);">&nbsp;</td>
              <td onClick="getIE(this);">&nbsp;</td>
              <td onClick="getIE(this);">&nbsp;</td>
              <td onClick="getIE(this);">&nbsp;</td>
              <td onClick="getIE(this);">&nbsp;</td>
            </tr>
            <tr bgcolor="#A6AE8C"> 
              <td onClick="getIE(this);">&nbsp;</td>
              <td onClick="getIE(this);">&nbsp;</td>
              <td onClick="getIE(this);">&nbsp;</td>
              <td onClick="getIE(this);">&nbsp;</td>
              <td onClick="getIE(this);">&nbsp;</td>
            </tr>
            <tr bgcolor="#A6AE8C"> 
              <td onClick="getIE(this);">&nbsp;</td>
              <td onClick="getIE(this);">&nbsp;</td>
              <td onClick="getIE(this);">&nbsp;</td>
              <td onClick="getIE(this);">&nbsp;</td>
              <td onClick="getIE(this);">&nbsp;</td>
            </tr>
            <tr bgcolor="#A6AE8C"> 
              <td onClick="getIE(this);">&nbsp;</td>
              <td onClick="getIE(this);">&nbsp;</td>
              <td onClick="getIE(this);">&nbsp;</td>
              <td onClick="getIE(this);">&nbsp;</td>
              <td onClick="getIE(this);">&nbsp;</td>
            </tr>
            <tr bgcolor="#A6AE8C"> 
              <td onClick="getIE(this);">&nbsp;</td>
              <td onClick="getIE(this);">&nbsp;</td>
              <td onClick="getIE(this);">&nbsp;</td>
              <td onClick="getIE(this);">&nbsp;</td>
              <td onClick="getIE(this);">&nbsp;</td>
            </tr>
          </table></td>
      </tr>
    </table></body>
    </html>
      

  2.   

    只能是在页面这个范围内,显示范围.
    如果加入工具栏,地址栏的话,不行.因为,不同浏览器,Myie,腾讯TT.
    这些工具栏,地址栏长度不一样.<body>
    000
    <table id="tb">
    <tr><td>灰豆宝宝.net</td></tr>
    </table>
    <input type=button onclick="get()" value="get">
    <script>
    function get()
    {
       var bao = tb.offsetTop;
       bao += document.body.clientTop;
       alert(bao)
    }
    </script>
    </body>