offsetTop Property--------------------------------------------------------------------------------Retrieves the calculated top position of the object relative to the layout or coordinate parent, as specified by the offsetParent property. SyntaxHTML N/A 
Scripting [ iCoord = ] object.offsetTop Possible ValuesiCoord Integer that receives the top position, in pixels. The property is read-only. The property has no default value.Expressions can be used in place of the preceding value(s), as of Microsoft?Internet Explorer 5. For more information, see Dynamic Properties.ResYou can determine the location, width, and height of an object by using a combination of the offsetLeft, offsetTop, offsetHeight, and offsetWidth properties. These numeric properties specify the physical coordinates and dimensions of the object relative to the object's offset parent. For more information about how to access the dimension and location of objects on the page through the Dynamic HTML (DHTML)燚ocument Object Model (DOM), see Measuring Element Dimension and Location. ExampleThis example uses the offsetTop property to determine whether an object is in the user's view.<SCRIPT>
function isinView(oObject)
{
    var oParent = oObject.offsetParent; 
    var iOffsetTop = oObject.offsetTop;
    var iClientHeight = oParent.clientHeight;
    if (iOffsetHeight > iClientHeight) {
        alert("Scroll down for the message.");
    }
}
</SCRIPT>
:
<BUTTON onclick="isinView(this)">Click here</BUTTON>
:
<DIV ID=oDiv STYLE="position:absolute; top:900; left:0;">
:
</DIV>

解决方案 »

  1.   

    <div style="position:absolute;top:0;width:100;height:100;background-color:red"></div>
      

  2.   

    回复 zhfkiller(杀手) :
    在Div中增加了position:absolute原来的overflow:hidden就不好用了,隐藏不了。
      

  3.   

    我测试着没有问题呀:
    <input type=button value=ok onclick="mm()"><br>
    <input type=button value='H/S'
     onclick="with(document.all.dd.style){display=(display=='none')?'':'none'}">
    <div id=dd style="overflow: auto; width: 400; height: 200; background: red">
    <table border=1 cellspacing=0 width=100% id=tab></table></div>
    <SCRIPT LANGUAGE="JavaScript">
    function mm()
    {
      var tab = document.all.tab;
      var tr  = tab.insertRow();
      var td  = tr.insertCell();
      td.innerText = 'meizz';
    }
    </SCRIPT>
      

  4.   

    TO:meizz(梅花雪) 
    行数少了不会出现问题,行数多了就不行了。
    不过我已经解决了,方法是把DIV中的TABLE的POSITION设为ABSOLUTE,就好用了。
    还是谢谢你。