应该是this有问题,this是本表格了吧,用this.name

解决方案 »

  1.   

    都不行
    table<script type="text/javascript">  
    function disable(o)  
    {  
    o=document.getElementById('base0');
    with (aa.style)  
    {  
    position = "absolute";  
    backgroundColor = "#000000";  
    width = o.offsetWidth;  
    height = o.offsetHeight;  
    left = o.offsetLeft;  
    top = o.offsetTop;  
    }
    }  
    </script> 
    <div id="aa"></div>
    <table>
      <tr>
        <td><input name='base' id='base0' type='checkbox' value='hhh' onMousemove="javascript:disable('base0');"/> hhh</td>
      </tr>
    </table>
      <input name='base' id='base1' type='checkbox' value='hhh' onMousemove='javascript:disable(this);'/> hhh
    就是那个对象
      

  2.   

    - -
    这个函数看起来好面熟的样子。。
    放table 里不行的原因是。。table有点异类..
    它的td的offsetHeight|Width是0
    但是你可以用offsetParent什么的取绝对的位置..
      

  3.   

    while (oLay.offsetParent) { oLay = oLay.offsetParent; iLeft += oLay.offsetLeft; iTop += oLay.offsetTop; }
    这样在ie能获取位置了
    在ff又不行(加上dtd)
    为什么
      

  4.   

    rePosition : function (o) {
    //获取元素绝对位置
    var $x = $y = 0;
    do {
    $x += o.offsetLeft;
    $y += o.offsetTop;
    } while ((o = o.offsetParent) && o.tagName != "BODY");
    return { x : $x, y : $y };
    }
      

  5.   

    获取位置
    加DTD没关系。。
      

  6.   

    问题是加了
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    后ie没问题
    ff就有问题
    ls的ls的方法基本跟我的相同吧
      

  7.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <script>
    function set(){
    var oLay = document.getElementById("inputer"), oDiv = document.getElementById("oList");
    var iLeft = oLay.offsetLeft, iTop = oLay.offsetHeight + oLay.offsetTop;
    while (oLay.offsetParent) { oLay = oLay.offsetParent; iLeft += oLay.offsetLeft; iTop += oLay.offsetTop; }
    with (oDiv.style) { top = iTop; left = iLeft;}
    }
    </script>
    </head>
    <body onload="set()">
    <div id="oList" style="position:absolute;border:1px solid #000;">123456</div>
    <table align="center" width="200" border="1">
    <tr><td>
    <input type="text" id="inputer"/>
    </td></tr>
    </table>
    </body>像这里ie正常ff不行
    没有dtd就两个都没问题
      

  8.   

    昂,你忘记加单位了。。
    必须要+ "px";
    正确的Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <script type="text/javascript">
    window.onload = function () {
    var oLay = document.getElementById("inputer"), oDiv = document.getElementById("oList");
    var iLeft = oLay.offsetLeft, iTop = oLay.offsetHeight + oLay.offsetTop;
    while (oLay.offsetParent) { oLay = oLay.offsetParent; iLeft += oLay.offsetLeft; iTop += oLay.offsetTop; }
    with (oDiv.style) { top = iTop + "px"; left = iLeft + "px";}
    }
    </script>
    </head>
    <body>
    <div id="oList" style="position:absolute;border:1px solid #000;">123456</div>
    <table align="center" width="200" border="1">
    <tr><td>
    <input type="text" id="inputer"/>
    </td></tr>
    </table>
    </body>