<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title></title>
<script language="javascript">function show(){ if(tb1.children[0].children[0].children[0].clientWidth - 3 >= tb1.children[0].children[0].children[0].width)
alert('满了');
}</script>
</head><body>
<table id="tb1">
<tr >
<td width="100">eeeeeeeeeeeeee</td>
<td style="width:50px">其它内容</td>
</tr>
</table><input type=button value="alert" onclick="show()">
</body>
</html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title></title>
<script language="javascript">function show(){ if(tb1.children[0].children[0].children[0].clientWidth - 3 >= tb1.children[0].children[0].children[0].width)
alert('满了');
}</script>
</head><body>
<table id="tb1">
<tr >
<td width="100">eeeeeeeeeeeeee</td>
<td style="width:50px">其它内容</td>
</tr>
</table><input type=button value="alert" onclick="show()">
</body>
</html>
JS里面那几个长宽的属性值值老是搞不清楚...请楼上的大虾解释下...
width, clientWidth, offsetWidth, scrollWidth
@_@
1. 先创建textrange对象
var range = document.createTextrange();
2. 找到td1的子对象,假设td1为那个单元格,同时假设td1只有一个子对象
var element = td1.childNodes[0];
3. 移动textrange来包含指定的对象
range.moveToElementText(element);
4. 取得td中文字的rect对象
var childHeight = range.boundingHeight;
var childWidth = range.boundingWidth;
5. 获取td1的客户端的高度和宽度
var height = td1.clientHeight;
var width = td1.clientWidth;大致是这样一个过程,其中的一些属性的大小写不一定对,具体你可以查一查文档。具体能不是实现我没有试过,可能很多地方都得改吧!
word-break:break-all;word-wrap:break-word