谢谢net_lover(孟子E章)。
您的例子我还没有仔细研究,先询问一下,我的表格中很多列的内容都是几十个几百个字的,肯定不该在一行中显示(太宽了),
不知道您的这个例子对于折了行的情况还能表现的那么好吗?
您的例子我还没有仔细研究,先询问一下,我的表格中很多列的内容都是几十个几百个字的,肯定不该在一行中显示(太宽了),
不知道您的这个例子对于折了行的情况还能表现的那么好吗?
看看这个如何!
应该有用
function asyncHeight()
{
t1=document.all.T1
t2=document.all.T2
for(i=0;i<t1.rows.length;i++)
{
t1.rows[i].cells[0].innerText += "增加"
t2.rows[i].cells[0].style.width = t1.rows[i].cells[0].offsetWidth
t2.rows[i].cells[0].style.height = t1.rows[i].cells[0].offsetHeight
}}
</script>
<input type=button value=修改 onclick="asyncHeight()">
<table id=T1 border width=100 align=left>
<tr>
<td>1</td><td>2</td>
</tr>
<tr>
<td>1</td><td>2</td>
</tr>
<tr>
<td>1</td><td>2</td>
</tr>
<tr>
<td>1</td><td>2</td>
</tr>
</table><table id=T2 border width=100>
<tr>
<td>1</td><td>2</td>
</tr>
<tr>
<td>1</td><td>2</td>
</tr>
<tr>
<td>1</td><td>2</td>
</tr>
<tr>
<td>1</td><td>2</td>
</tr>
</table>
现在在忙另外一个BUG。下午来研究你们提供的东西。有问题的话再来请教。
调整窗口大小,可以看到相关效果
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>JK:支持民族工业,尽量少买X货</title>
<style>
.fixedHeaderTr
{
position:relative;
top:expression(this.offsetParent.scrollTop);
}; .mainDiv
{
overflow:auto;
scrollbar-face-color:9999ff;
height:expression((document.body.clientHeight-this.offsetTop-20>this.children[0].offsetHeight)?(this.children[0].offsetHeight+20) : (document.body.clientHeight-this.offsetTop-20));
width:expression(document.body.clientWidth-20);
}
</style>
</head> <body>
部分代码来自:<br>http://blog.csdn.net/wu_yongcai/archive/2004/11/21/189816.aspx
<br>
<div class="mainDiv">
<table width="100%" border=1 cellspacing=0 style="margin-top:-2px" >
<TR class="fixedHeaderTr" style="background:navy;color:white;">
<TD nowrap>Header A</TD>
<TD nowrap>Header B</TD>
<TD nowrap>Header C</TD>
</TR>
<TR>
<TD>A</TD>
<TD>B</TD>
<TD nowrap >
C部分代码来自:<br>
http://blog.csdn.net/wu_yongcai/archive/2004/11/21/189816.aspx</TD>
</TR>
<TR>
<TD>A</TD>
<TD>B</TD>
<TD>C</TD>
</TR>
<TR>
<TD>A</TD>
<TD>B</TD>
<TD>C</TD>
</TR>
<TR>
<TD>A</TD>
<TD>B</TD>
<TD>C</TD>
</TR>
<TR>
<TD>A</TD>
<TD>B</TD>
<TD>C</TD>
</TR>
<TR>
<TD>A</TD>
<TD>B</TD>
<TD>C</TD>
</TR>
<TR>
<TD>A</TD>
<TD>B</TD>
<TD>C</TD>
</TR>
<TR>
<TD>A</TD>
<TD>B</TD>
<TD>C</TD>
</TR>
<TR>
<TD>A</TD>
<TD>B</TD>
<TD>C</TD>
</TR>
</table>
</div>
</body>
</html>