<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style>
.resizeDivClass
{
position:absolute;
background-color:gray;
width:1;
z-index:1;
left:1;
cursor:e-resize;
}
.td1 {
font-size: 12px;
white-space:nowrap;
overflow:hidden;
text-overflow:ellipsis;
color:#0000ff;
pos:expression(this.offsetLeft*1+this.offsetWidth*1+tab.offsetLeft);
}
</style>
<script language=javascript>
function MouseDownToResize(obj){
obj.mouseDownX=event.clientX;
obj.pareneTdW=obj.parentElement.offsetWidth;
obj.pareneTableW=tab.offsetWidth;
obj.setCapture();
}
function MouseMoveToResize(obj){
if(!obj.mouseDownX) return false;
var newWidth=obj.pareneTdW*1+event.clientX*1-obj.mouseDownX;
if(newWidth>0)
{
obj.parentElement.style.width = newWidth;
tab.style.width=obj.pareneTableW*1+event.clientX*1-obj.mouseDownX;
for (var i=1; i<=tab.rows(0).cells.length;i++){
var obj = eval("mydiv"+i);
obj.style.left = obj.parentElement.offsetLeft*1+obj.parentElement.offsetWidth*1+tab.offsetLeft;//obj.parentElement.style.pos;
}
}
}
function MouseUpToResize(obj){
obj.releaseCapture();
obj.mouseDownX=0;
}
function init(){
var tempStr = "";
for (var i=1; i<=tab.rows(0).cells.length;i++){
tempStr = '<div id="mydiv'+i+'" class="resizeDivClass" onmousedown="MouseDownToResize(this);" onmousemove="MouseMoveToResize(this);" onmouseup="MouseUpToResize(this);"></div>';
tab.rows(0).cells(i-1).innerHTML = tab.rows(0).cells(i-1).innerHTML+tempStr;
var obj = eval("mydiv"+i);
obj.style.left = obj.parentElement.style.pos;
}
}
</script>
</head>
<body onload="init()">
<table id=tab STYLE="table-layout:fixed;" >
<tr bgcolor=cccccc >
<td valign=top class="td1" ><nobr>改变table的列宽度改</nobr></td>
<td valign=top class="td1" ><nobr>改变table的列宽度改</nobr></td>
<td valign=top class="td1" ><nobr>改变table的列宽度改</nobr></td>
</tr>
<tr>
<td class="td1"><nobr>改变table的列宽度</nobr></td>
<td class="td1"><nobr>改变table的列宽度</nobr></td>
<td class="td1"><nobr>改变table的列宽度</nobr></td>
</tr>
</table>
</body>
</html>