表格显示不下字符串截断用...代替怎么办? <table border=1 width=100><tr><td><div nowrap style="width:100; overflow:hidden">这里就是你想要显示的内容</div></td></tr></table> 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="386" height="163" id="AutoNumber1"> <tr> <td width="12" height="52" id= t1> </td> <td width="102" height="52"> </td> <td width="143" height="52"> </td> </tr> </table> <input type = button value = sub onclick=sub()><script>function sub(){ var str= '1111111111112222222222222222222222222222222333333333333333333333334444444444444444444445555555555'; if (str.length>5) { t1.innerText = str.substr(1,5)+'...'; }} </script> 多谢两位!不过我象要的效果是显示不下时就将后面的用...表示,没有...是不可以的,这样的话界面会不友好。但是我也不知道能够显示的字符个数,所以没有办法采用substr(),且后续补...各位帮帮忙,看有什么好方法。 有个css方法来着,不过得ie6吧,等我查查 "不知道能够显示的字符个数"是什么意思?有length啊。 table的style中有个table-layout属性,设置为fixed能满足你的要求。相关属性设置可参考MSDN CSS可以自动在后面加...不过对中文支持极差.还是自己写程序吧.<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="386" height="163" id="AutoNumber1"> <tr> <td width="12" height="52" id= t1> </td> <td width="102" height="52"> </td> <td width="143" height="52"> </td> </tr> </table> <input type = button value = sub onclick=sub()><script>function sub(){ var str= '1111111111112222222222222222222222222222222333333333333333333333334444444444444444444445555555555'; if (str.length>5) { t1.innerText = str.substr(1,5)+'...'; }} </script>----------------------上面程序唯一的不足就是6个英文与6个汉字都会同样处理,但6个英文明显比5个汉字短.可以用下面的程序:<td width=50 id=t1>111了在工在发厅ABCDD<td><td width=50 id=t2>abc<td><script>function f1(){iWidth=parseInt(t1.width) while(t1.clientWidth>iWidth)//clientWidth为TD的实际宽度,width为TD定义的宽度,不会跟着TD变宽的{ t1.innerText=t1.innerText.substr(0,t1.innerText.length-4)+"..."}}</script> 找到:text-overflow;和overflow<DIV STYLE="position: absolute; left: 0px; top: 18px; color: black; width: 120px; height: 50px; border: 1px solid blue; font: 14px Times New Roman, serif; overflow: hidden; text-overflow:ellipsis"><nobr>在指定列宽asdfasdfsdd的表格中显示字符串,如果一列的宽度不足以显示所有的字符,而客户</nobr></DIV> 求人帮写个正则表达式 如何将以下的JAVASCRIPT代码改写为C# 超难问题 如何用js 将htm网页中的表格导出成word或excel? 插入图片问题? frame和iframe的区别是什么? 用js控制播放器问题---参数不会写 大家来看看这个算法:有关数字转换成中文大写 js中怎样判断select下拉框的选择内容?在线等 兄弟们快帮我呀 大家有没有发现360浏览器版本6.x后很多正常用到的js不能用了,请问如何解决? 请问如何通过命令在表单里动态添加一个按钮? 如何用JavaScript写XML文件
<tr>
<td width="12" height="52" id= t1> </td>
<td width="102" height="52"> </td>
<td width="143" height="52"> </td>
</tr>
</table>
<input type = button value = sub onclick=sub()><script>
function sub()
{ var str= '1111111111112222222222222222222222222222222333333333333333333333334444444444444444444445555555555';
if (str.length>5)
{
t1.innerText = str.substr(1,5)+'...';
}
}
</script>
各位帮帮忙,看有什么好方法。
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="386" height="163" id="AutoNumber1">
<tr>
<td width="12" height="52" id= t1> </td>
<td width="102" height="52"> </td>
<td width="143" height="52"> </td>
</tr>
</table>
<input type = button value = sub onclick=sub()><script>
function sub()
{ var str= '1111111111112222222222222222222222222222222333333333333333333333334444444444444444444445555555555';
if (str.length>5)
{
t1.innerText = str.substr(1,5)+'...';
}
}
</script>
----------------------
上面程序唯一的不足就是6个英文与6个汉字都会同样处理,但6个英文明显比5个汉字短.
可以用下面的程序:
<td width=50 id=t1>111了在工在发厅ABCDD<td>
<td width=50 id=t2>abc<td>
<script>function f1()
{
iWidth=parseInt(t1.width) while(t1.clientWidth>iWidth)//clientWidth为TD的实际宽度,width为TD定义的宽度,不会跟着TD变宽的
{
t1.innerText=t1.innerText.substr(0,t1.innerText.length-4)+"..."
}}
</script>
width: 120px; height: 50px; border: 1px solid blue;
font: 14px Times New Roman, serif; overflow: hidden;
text-overflow:ellipsis">
<nobr>在指定列宽asdfasdfsdd的表格中显示字符串,如果一列的宽度不足以显示所有的字符,而客户</nobr>
</DIV>