日期:2014-05-16 浏览次数:20390 次
<table width="100%" border="0"> <tr> <td> </td> </tr> <tr> <td> </td> </tr> <tr> <td> </td> </tr> </table>
<TITLE> 分隔条 </TITLE> <script language="javascript"> <!-- //------------------------------------ // CopyRight (c) 宝玉 2006 //------------------------------------ var oSplitter, oTdSplitter, oTdTop, oTdBot, oTable; var posTdSplitter, posTable; var bLoaded = false; var bStart = false; var iPadding = 0; function Position(x, y) { this.x = x; this.y = y; } function GetPosition(obj) { var objThis = obj; var oBody = document.body; var oLeft = oTop = 0; while (objThis!=oBody) { oLeft += objThis.offsetLeft; oTop += objThis.offsetTop; objThis = objThis.offsetParent; } return new Position(oLeft, oTop); } function fnInit() { oSplitter = document.getElementById("splitter"); oTdSplitter = document.getElementById("tdSplitter"); oTdTop = document.getElementById("tdTop"); oTdBot = document.getElementById("tdBot"); oTable = document.getElementById("table"); posTable = GetPosition(oTable); oSplitter.style.height = oTdSplitter.offsetHeight; oSplitter.style.width = oTdSplitter.offsetWidth; bLoaded = true; } function fnMouseDown(event) { if (bLoaded == false) { alert("页面加载未完成,请稍候!"); return; } posTdSplitter = GetPosition(oTdSplitter); iPadding = posTdSplitter.y - event.clientY; oSplitter.style.top = posTdSplitter.y; oSplitter.style.left = posTdSplitter.x; oSplitter.style.display = "block"; if (oSplitter.setCapture) oSplitter.setCapture(); bStart = true; } function fnMouseUp(event) { if (bStart == true) { oSplitter.style.display = "none"; if (event.clientY > posTable.y && event.clientY < posTable.y + oTable.offsetHeight - oTdSplitter.offsetHeight) { oTdTop.style.height = event.clientY - posTable.y; } if (oSplitter.releaseCapture) oSplitter.releaseCapture(); bStart = false; } } function fnMouseMove(event) { if (bStart == true) { oSplitter.style.top = event.clientY + iPadding; } } //--> </script> </HEAD> <body onload="fnInit();" onmouseup="fnMouseUp(event);" onmousemove="fnMouseMove(event);" style="margin:0px;" onselectstart="return false;"> <div style="position: absolute;width:4px;height:400px;background-color: black;z-index:9999;display:none;cursor: col-resize;" id="splitter"></div> <table cellspacing="0" cellpadding="0" border="0" style="height:100%; width:100%;" id="table"> <tr> <td id="tdTop" > </td> </tr> <tr> <td style="height: 8px; overflow:hidden;cursor: col-resize;border-top:1px solid black;border-bottom:1px solid black;" id="tdSplitter" onmousedown="fnMouseDown(event);"> </td> </tr> <tr> <td id="tdBot" > </td> </tr> </table> </body> </HTML>
------解决方案--------------------
顶+学习~
------解决方案--------------------
<h