<Script language="Javascript">
function get10Length(str)

n=20
var tmp = 0;
var len = 0;
var okLen = 0
for(var i=0;i<n;i++)
{
if(str.charCodeAt(i)>255)
tmp += 2 
else
len += 1
okLen += 1
if(tmp + len == n) 
{
return (str.substring(0,okLen));
break;
}
if(tmp + len > n)
{
return (str.substring(0,okLen - 1) + "&nbsp;"); 
break;
}
}

</Script>
<body onload="mxh.innerHTML=get10Length(mxh.title);mxh2.innerHTML=get10Length(mxh2.title)">
<TABLE border=1>
<TR><TD ID=mxh title="测试文章测试文章测试文章测试文章测试文章测试文章"></td>
<TR><TD ID=mxh2 title="测s试ew文d章s测f试文章测试文章测试文章测试文章测试文章"></td>
</TR>
</TABLE> 

解决方案 »

  1.   

    <style>.qswh{width:180;text-overflow:ellipsis;overflow-x:hidden}</style>
    <div class=qswh><nobr>测试文章测试文章测试文章测试文章测试文章测试文章<nobr></div>
    <div class=qswh><nobr>测s试ew文d章s测f试文章测试文章测试文章测试文章测试文章<nobr></div>
      

  2.   

    http://www.csdn.net/Develop/My_Article.asp?author=net_lover服务器端脚本
      

  3.   

    <table style='width:100;table-layout:fixed'
     onmouseover="this.style.tableLayout='auto'"
     onmouseout="this.style.tableLayout='fixed'">
    <td height=18 nowrap>测s试ew文d章s测f试文章测试文章测试文章测试文章测试文章</td>
    </table>
      

  4.   

    to net_lover(孟子E章):
    我试过了,页面报错,请看看我的程序:
    <table width="100%" border="0"  bgcolor="#E3ECF2" >
      <tr><td width="100%" class="tr1"><b >新闻专题</b></td></tr>  <%   ArrayList topicinfs = TopicInf.findByAll();
         Iterator it = topicinfs.iterator();
         while (it.hasNext()) {
            TopicInf topicinf = (TopicInf) it.next();        
    %>
      <tr>

        <td > 
          <table width="100%" border="0" align="left" cellpadding="0"  class="font3">
    <tr> 
      
              <td align="left"  > 
                <b><%= topicinf.getName() %></b> <a href="moretopic.jsp?topic=<%=topicinf.getName()%>">More...</a> 
              </td>
    </tr>
    <% ArrayList newsinfs = NewsInf.getTopicNews(topicinf.getName(), 3);
       Iterator it2 = newsinfs.iterator();
                                       while (it2.hasNext()) {
                                       NewsInf newsinf = (NewsInf) it2.next();
    %>
    <tr> 
     “ <td><SPAN class=td1>● </SPAN><a href="newsinfo.jsp?nid=<%=newsinf.getNid()%>"><%= newsinf.getTitle()%></a></td>“
    </tr>
    <% } %>
    </table>
    </td>
    </tr>
    <% } %>
    </table>我是想显示标题,标题是循环的,并且与下一页连接,它的长度不能超过10个汉字
    并且我这一页是一个包含在index.jsp中的一个jsp,那么我的<script></script>加在哪一个jsp上?