表格单元格的宽度与高度是自由拖动来改变,但如何从中拿到单元格的宽度值呢?

janet168 2003-05-28 09:04:55
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>table</title>
<SCRIPT LANGUAGE="JavaScript">
<!--
var startx=0;
var mousePress=false;
var destElm;
var oldWidth=40;
function down()
{
startx = event.x;
mousePress=true;
with (event.srcElement)
destElm = parentNode.cells[cellIndex-1]
oldWidth = destElm.offsetWidth;
}
function up()
{
mousePress=false;
}
function move()
{
if (!mousePress) return;
var d=event.x-startx+oldWidth;
if (d>0) destElm.width=d;
}
//-->
</SCRIPT>
<style>
.left {border-left:1px solid black}
.top {border-top:1px solid black}
.left-top {border-top:1px solid black;border-left:1px solid black}
TABLE{border:1px solid black}
</style>
</head>
<body onmousemove=move() onmouseup=up()>
<table>
<tr>
<td>IPC</td><td style="cursor:e-resize;" onmousedown=down()></td>
<td class=left>IPC</td><td style="cursor:e-resize" onmousedown=down()></td>
<td class=left>IPC</td><td style="cursor:e-resize" onmousedown=down()></td>
<td class=left>IPC</td><td style="cursor:e-resize" onmousedown=down()></td>
</tr>
<tr>
<td class=top>fgqa</td><td style="cursor:e-resize" onmousedown=down()></td>
<td class=left-top>fgqa</td><td style="cursor:e-resize" onmousedown=down()></td>
<td class=left-top>fgqa</td><td style="cursor:e-resize" onmousedown=down()></td>
<td class=left-top>fgqa</td><td style="cursor:e-resize" onmousedown=down()></td>
</tr>
<tr>
<td class=top>fgqa</td><td style="cursor:e-resize" onmousedown=down()></td>
<td class=left-top>fgqa</td><td style="cursor:e-resize" onmousedown=down()></td>
<td class=left-top>fgqa</td><td style="cursor:e-resize" onmousedown=down()></td>
<td class=left-top>fgqa</td><td style="cursor:e-resize" onmousedown=down()></td>
</tr>
</table>

</body>
</html>
...全文
86 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
xhan2000 2003-06-05
  • 打赏
  • 举报
回复
转为服务器控件或使用script

1,979

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 其他语言讨论
社区管理员
  • 其他语言社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧