大家一起讨论一下能动态定义表格的开头某几列或者某几行可以不随表格滚动的方法? 看看这个:http://expert.csdn.net/Expert/topic/2848/2848255.xml?temp=.8958704 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 http://www.51windows.net/hw/asp/jsview.asp?id=314 建议在IE6下浏览。拖动标题上的白色分隔边框可以实现调整列宽。<HTML><head><title>自定义表格</title><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><meta content=0 http-equiv=Expires><style><!--body{ font-size: 12px; margin-top: 0pt; margin-left: 10pt; margin-right: 10pt; color: #000000; font-family: arial, 'trebuchet ms', helvetica; background-color: #D4D0C8;}nobr{ font-size: 12px;}table.list{ border : 0px; background-color: #808080;}tr.listTitle{ font-size: 12px; background-color: #D4D0C8;}tr.listContent{ font-size: 12px; background-color: #ffffff;}span{ overflow: hidden; width: 100%; text-overflow: ellipsis;}--></style></head><body onresize="setScroll()" onload="setBorder(0)" onmouseup="release()" style="overflow :hidden;"><div onmouseover="this.style.backgroundColor='#000000'" onmouseout="this.style.backgroundColor='#ffffff'" onmousedown="init()" index="0" id="theBorder" name="theBorder" style="width:1px;position:absolute;cursor:e-resize;background-color:#ffffff;"></div><div onmouseover="this.style.backgroundColor='#000000'" onmouseout="this.style.backgroundColor='#ffffff'" onmousedown="init()" index="1" id="theBorder" name="theBorder" style="width:1px;position:absolute;cursor:e-resize;background-color:#ffffff;"></div><div onmouseover="this.style.backgroundColor='#000000'" onmouseout="this.style.backgroundColor='#ffffff'" onmousedown="init()" index="2" id="theBorder" name="theBorder" style="width:1px;position:absolute;cursor:e-resize;background-color:#ffffff;"></div><div onmouseover="this.style.backgroundColor='#000000'" onmouseout="this.style.backgroundColor='#ffffff'" onmousedown="init()" index="3" id="theBorder" name="theBorder" style="width:1px;position:absolute;cursor:e-resize;background-color:#ffffff;"></div><div onmouseover="this.style.backgroundColor='#000000'" onmouseout="this.style.backgroundColor='#ffffff'" onmousedown="init()" index="4" id="theBorder" name="theBorder" style="width:1px;position:absolute;cursor:e-resize;background-color:#ffffff;"></div><div onmouseover="this.style.backgroundColor='#000000'" onmouseout="this.style.backgroundColor='#ffffff'" onmousedown="init()" index="5" id="theBorder" name="theBorder" style="width:1px;position:absolute;cursor:e-resize;background-color:#ffffff;"></div><div onmouseover="this.style.backgroundColor='#000000'" onmouseout="this.style.backgroundColor='#ffffff'" onmousedown="init()" index="6" id="theBorder" name="theBorder" style="width:1px;position:absolute;cursor:e-resize;background-color:#ffffff;"></div><div onmouseover="this.style.backgroundColor='#000000'" onmouseout="this.style.backgroundColor='#ffffff'" onmousedown="init()" index="7" id="theBorder" name="theBorder" style="width:1px;position:absolute;cursor:e-resize;background-color:#ffffff;"></div><table id="mainTable" class="list" height="100%" width="100%" cellspacing="0" cellpadding="0" border="0"><tr class="listTitle" height="20"><td> <span id="theScroll" name="theScroll" style="height:100%;width:100%;overflow:hidden;"> <table class="list" style="height:100%;width:100%;border-collapse : collapse;table-layout: fixed;" cellspacing="1" cellpadding="0" border="0"> <tr class="listTitle"> <td width="80"><span><nobr>ID号</nobr></span></td> <td width="80"><span><nobr>ID号ID号ID号ID号ID号ID号</nobr></span></td> <td width="80"><span><nobr>编号</nobr></span></td> <td width="80"><span><nobr>姓名</nobr></span></td> <td width="80"><span><nobr>别名</nobr></span></td> <td width="80"><span><nobr>代号</nobr></span></td> <td width="80"><span><nobr>绰号</nobr></span></td> <td width="80"><span><nobr>性别</nobr></span></td> <td></td> </tr> </table> </span></td><td width="16"> </td></tr><tr class="listTitle"><td colspan="2"> <span id="theScroll" name="theScroll" style="height:100%;width:100%;overflow-x:auto;overflow-y:scroll;" onscroll="setScroll()"> <table class="list" style="height:100%;width:100%;border-collapse : collapse;table-layout: fixed;" cellspacing="1" cellpadding="0" border="0"><script><!--for (var i=0;i<30;i++){ document.write("<tr class=\"listContent\">"); document.write("<td width=\"80\"><span><nobr><a href=\"#\">02000000000001</a></nobr></span></td>"); document.write("<td width=\"80\"><span><nobr>02000000000001</nobr></span></td>"); document.write("<td width=\"80\"><span><nobr>"+i+"</nobr></span></td>"); document.write("<td width=\"80\"><span><nobr>姓名</nobr></span></td>"); document.write("<td width=\"80\"><span><nobr>姓\r\n名</nobr></span></td>"); document.write("<td width=\"80\"><span><nobr>按时大苏打按时大苏打</nobr></span></td>"); document.write("<td width=\"80\"><span><nobr>234565477234565477</nobr></span></td>"); document.write("<td width=\"80\"><span><nobr>$^$%&^&*$^$%&^&*</nobr></span></td>"); document.write("<td></td>"); document.write("</tr>");}--></script> </table> </span></td></tr><tr class="listTitle" height="20"><td> <span id="theScroll" name="theScroll" style="height:100%;width:100%;overflow :hidden;"> <table class="list" style="height:100%;width:100%;border-collapse : collapse;table-layout: fixed;" cellspacing="1" cellpadding="0" border="0"> <tr class="listTitle"> <td width="80"><span><nobr>ID号</nobr></span></td> <td width="80"><span><nobr>ID号ID号ID号ID号ID号ID号</nobr></span></td> <td width="80"><span><nobr>编号</nobr></span></td> <td width="80"><span><nobr>姓名</nobr></span></td> <td width="80"><span><nobr>别名</nobr></span></td> <td width="80"><span><nobr>代号</nobr></span></td> <td width="80"><span><nobr>绰号</nobr></span></td> <td width="80"><span><nobr>性别</nobr></span></td> <td> </td> </tr> </table> </span></td><td width="16"> </td></tr></table></body></html> <script><!--var tmpPosition = null;var border = null;function setBorder(leftMove){ for (var i=0;i<mainTable.cells(0).children(0).children(0).rows(0).cells.length-1;i++){ theBorders = document.getElementsByName("theBorder"); theBorders[i].style.top = getIEPos(mainTable.cells(0).children(0).children(0).rows(0),"Top"); theBorders[i].style.height = mainTable.cells(0).children(0).children(0).rows(0).offsetHeight; theBorders[i].style.left = getIEPos(mainTable.cells(0).children(0).children(0).rows(0).cells(i+1),"Left")-1-leftMove; }}function init(){ if (event.srcElement.tagName!="DIV"){ return false; } tmpPosition = event.clientX; border = event.srcElement; event.srcElement.attachEvent("onmousemove",move); event.srcElement.setCapture();}function release(){ if (border!=null){ border.detachEvent("onmousemove",move); border.releaseCapture(); border.style.backgroundColor="#ffffff"; }}function move(){ var wid = parseInt(mainTable.rows(0).cells(0).children(0).children(0).rows(0).cells(parseInt(border.index)).width)+(event.clientX-tmpPosition); if (wid < 1){ wid = 1; } mainTable.rows(0).cells(0).children(0).children(0).rows(0).cells(parseInt(border.index)).width = wid; for (var j=0;j<mainTable.rows(1).cells(0).children(0).children(0).rows.length;j++){ mainTable.rows(1).cells(0).children(0).children(0).rows(j).cells(parseInt(border.index)).width = wid;//parseInt(mainTable.rows(1).cells(0).children(0).children(0).rows(j).cells(parseInt(border.index)).width)+(event.clientX-tmpPosition); } mainTable.rows(2).cells(0).children(0).children(0).rows(0).cells(parseInt(border.index)).width = wid;//parseInt(mainTable.rows(2).cells(0).children(0).children(0).rows(0).cells(parseInt(border.index)).width)+(event.clientX-tmpPosition); setBorder(0); tmpPosition = event.clientX;}function setScroll(){ theScrolls = document.getElementsByName("theScroll"); theScrolls[0].scrollLeft = theScrolls[1].scrollLeft; theScrolls[2].scrollLeft = theScrolls[1].scrollLeft; setBorder(theScrolls[1].scrollLeft);}function getIEPos(elt,which) {//get the absolute position of the object var iPos = 0; while (elt!=null) { iPos += elt["offset" + which]; elt = elt.offsetParent; } return iPos;}--></script> JS的数字处理能力这么不稳定?各大虾进来讨论下 jQuerymobile JS里一个伪包的例子,求解释... jquery easyinsert初始化的问题 跪求 如何获取激发一次滚轮事件中滚轮滚过长度(pixel) 动态添加表格 javascript修改form里的一些值以后如何阻止页面提交? 关于表单,cookies结合的问题,各们高手,帮帮忙啦。 JavaScript日期檢查 求一段js正则表达式 javascript读ASP的COOKIES(带汉字编码的)问题?急!急!急!急!急!急!急!急! 请问CSDN论坛左边的树状结构图是怎么做的,有源代码最好!高分相送。
拖动标题上的白色分隔边框可以实现调整列宽。<HTML>
<head>
<title>自定义表格</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta content=0 http-equiv=Expires>
<style>
<!--
body{
font-size: 12px;
margin-top: 0pt;
margin-left: 10pt;
margin-right: 10pt;
color: #000000;
font-family: arial, 'trebuchet ms', helvetica;
background-color: #D4D0C8;
}
nobr{
font-size: 12px;
}
table.list{
border : 0px;
background-color: #808080;
}
tr.listTitle{
font-size: 12px;
background-color: #D4D0C8;
}
tr.listContent{
font-size: 12px;
background-color: #ffffff;
}
span{
overflow: hidden;
width: 100%;
text-overflow: ellipsis;
}
-->
</style></head>
<body onresize="setScroll()" onload="setBorder(0)" onmouseup="release()" style="overflow :hidden;">
<div onmouseover="this.style.backgroundColor='#000000'" onmouseout="this.style.backgroundColor='#ffffff'" onmousedown="init()" index="0" id="theBorder" name="theBorder" style="width:1px;position:absolute;cursor:e-resize;background-color:#ffffff;"></div>
<div onmouseover="this.style.backgroundColor='#000000'" onmouseout="this.style.backgroundColor='#ffffff'" onmousedown="init()" index="1" id="theBorder" name="theBorder" style="width:1px;position:absolute;cursor:e-resize;background-color:#ffffff;"></div>
<div onmouseover="this.style.backgroundColor='#000000'" onmouseout="this.style.backgroundColor='#ffffff'" onmousedown="init()" index="2" id="theBorder" name="theBorder" style="width:1px;position:absolute;cursor:e-resize;background-color:#ffffff;"></div>
<div onmouseover="this.style.backgroundColor='#000000'" onmouseout="this.style.backgroundColor='#ffffff'" onmousedown="init()" index="3" id="theBorder" name="theBorder" style="width:1px;position:absolute;cursor:e-resize;background-color:#ffffff;"></div>
<div onmouseover="this.style.backgroundColor='#000000'" onmouseout="this.style.backgroundColor='#ffffff'" onmousedown="init()" index="4" id="theBorder" name="theBorder" style="width:1px;position:absolute;cursor:e-resize;background-color:#ffffff;"></div>
<div onmouseover="this.style.backgroundColor='#000000'" onmouseout="this.style.backgroundColor='#ffffff'" onmousedown="init()" index="5" id="theBorder" name="theBorder" style="width:1px;position:absolute;cursor:e-resize;background-color:#ffffff;"></div>
<div onmouseover="this.style.backgroundColor='#000000'" onmouseout="this.style.backgroundColor='#ffffff'" onmousedown="init()" index="6" id="theBorder" name="theBorder" style="width:1px;position:absolute;cursor:e-resize;background-color:#ffffff;"></div>
<div onmouseover="this.style.backgroundColor='#000000'" onmouseout="this.style.backgroundColor='#ffffff'" onmousedown="init()" index="7" id="theBorder" name="theBorder" style="width:1px;position:absolute;cursor:e-resize;background-color:#ffffff;"></div>
<table id="mainTable" class="list" height="100%" width="100%" cellspacing="0" cellpadding="0" border="0">
<tr class="listTitle" height="20">
<td>
<span id="theScroll" name="theScroll" style="height:100%;width:100%;overflow:hidden;">
<table class="list" style="height:100%;width:100%;border-collapse : collapse;table-layout: fixed;" cellspacing="1" cellpadding="0" border="0">
<tr class="listTitle">
<td width="80"><span><nobr>ID号</nobr></span></td>
<td width="80"><span><nobr>ID号ID号ID号ID号ID号ID号</nobr></span></td>
<td width="80"><span><nobr>编号</nobr></span></td>
<td width="80"><span><nobr>姓名</nobr></span></td>
<td width="80"><span><nobr>别名</nobr></span></td>
<td width="80"><span><nobr>代号</nobr></span></td>
<td width="80"><span><nobr>绰号</nobr></span></td>
<td width="80"><span><nobr>性别</nobr></span></td>
<td></td>
</tr>
</table>
</span>
</td>
<td width="16"> </td>
</tr>
<tr class="listTitle">
<td colspan="2">
<span id="theScroll" name="theScroll" style="height:100%;width:100%;overflow-x:auto;overflow-y:scroll;" onscroll="setScroll()">
<table class="list" style="height:100%;width:100%;border-collapse : collapse;table-layout: fixed;" cellspacing="1" cellpadding="0" border="0">
<script>
<!--
for (var i=0;i<30;i++){
document.write("<tr class=\"listContent\">");
document.write("<td width=\"80\"><span><nobr><a href=\"#\">02000000000001</a></nobr></span></td>");
document.write("<td width=\"80\"><span><nobr>02000000000001</nobr></span></td>");
document.write("<td width=\"80\"><span><nobr>"+i+"</nobr></span></td>");
document.write("<td width=\"80\"><span><nobr>姓名</nobr></span></td>");
document.write("<td width=\"80\"><span><nobr>姓\r\n名</nobr></span></td>");
document.write("<td width=\"80\"><span><nobr>按时大苏打按时大苏打</nobr></span></td>");
document.write("<td width=\"80\"><span><nobr>234565477234565477</nobr></span></td>");
document.write("<td width=\"80\"><span><nobr>$^$%&^&*$^$%&^&*</nobr></span></td>");
document.write("<td></td>");
document.write("</tr>");
}
-->
</script> </table>
</span>
</td>
</tr>
<tr class="listTitle" height="20">
<td>
<span id="theScroll" name="theScroll" style="height:100%;width:100%;overflow :hidden;">
<table class="list" style="height:100%;width:100%;border-collapse : collapse;table-layout: fixed;" cellspacing="1" cellpadding="0" border="0">
<tr class="listTitle">
<td width="80"><span><nobr>ID号</nobr></span></td>
<td width="80"><span><nobr>ID号ID号ID号ID号ID号ID号</nobr></span></td>
<td width="80"><span><nobr>编号</nobr></span></td>
<td width="80"><span><nobr>姓名</nobr></span></td>
<td width="80"><span><nobr>别名</nobr></span></td>
<td width="80"><span><nobr>代号</nobr></span></td>
<td width="80"><span><nobr>绰号</nobr></span></td>
<td width="80"><span><nobr>性别</nobr></span></td>
<td> </td>
</tr>
</table>
</span>
</td>
<td width="16"> </td>
</tr>
</table></body>
</html>
<!--var tmpPosition = null;
var border = null;function setBorder(leftMove){
for (var i=0;i<mainTable.cells(0).children(0).children(0).rows(0).cells.length-1;i++){
theBorders = document.getElementsByName("theBorder");
theBorders[i].style.top = getIEPos(mainTable.cells(0).children(0).children(0).rows(0),"Top");
theBorders[i].style.height = mainTable.cells(0).children(0).children(0).rows(0).offsetHeight;
theBorders[i].style.left = getIEPos(mainTable.cells(0).children(0).children(0).rows(0).cells(i+1),"Left")-1-leftMove;
}
}function init(){
if (event.srcElement.tagName!="DIV"){
return false;
}
tmpPosition = event.clientX;
border = event.srcElement;
event.srcElement.attachEvent("onmousemove",move);
event.srcElement.setCapture();
}function release(){
if (border!=null){
border.detachEvent("onmousemove",move);
border.releaseCapture();
border.style.backgroundColor="#ffffff";
}
}function move(){
var wid = parseInt(mainTable.rows(0).cells(0).children(0).children(0).rows(0).cells(parseInt(border.index)).width)+(event.clientX-tmpPosition);
if (wid < 1){
wid = 1;
}
mainTable.rows(0).cells(0).children(0).children(0).rows(0).cells(parseInt(border.index)).width = wid;
for (var j=0;j<mainTable.rows(1).cells(0).children(0).children(0).rows.length;j++){
mainTable.rows(1).cells(0).children(0).children(0).rows(j).cells(parseInt(border.index)).width = wid;//parseInt(mainTable.rows(1).cells(0).children(0).children(0).rows(j).cells(parseInt(border.index)).width)+(event.clientX-tmpPosition);
}
mainTable.rows(2).cells(0).children(0).children(0).rows(0).cells(parseInt(border.index)).width = wid;//parseInt(mainTable.rows(2).cells(0).children(0).children(0).rows(0).cells(parseInt(border.index)).width)+(event.clientX-tmpPosition);
setBorder(0);
tmpPosition = event.clientX;
}function setScroll(){
theScrolls = document.getElementsByName("theScroll");
theScrolls[0].scrollLeft = theScrolls[1].scrollLeft;
theScrolls[2].scrollLeft = theScrolls[1].scrollLeft;
setBorder(theScrolls[1].scrollLeft);
}function getIEPos(elt,which) {
//get the absolute position of the object
var iPos = 0;
while (elt!=null) {
iPos += elt["offset" + which];
elt = elt.offsetParent;
}
return iPos;
}-->
</script>