你用B类函数~~
lenb(str)
当然,长度要设置为20~~~

解决方案 »

  1.   

    <script>
    String.prototype.len=function()
    {
        return this.replace(/[^\x00-\xff]/g,"**").length;
    }
    var str="我a";
    alert(str.len());
    </script>
      

  2.   

    String.prototype.lenb= function()
    {
      return this.replace(/[^\x00-\xff]/g,"**").length;
    }
      

  3.   

    能不能详细点,看不懂,我初学。
    这是我的函数,其中t_name是传入的字符串,如"根据市场部门的要求应该加大投入",t_width是取得的表格中具体的列宽,具体数字是200px.我只对宽度为200px的列操作。function interceptString(t_name,t_width){
    var strLength = t_name.length;
    if ( t_width = 200 )   
    {
    var theString = t_name.substring(0,10) + '...';
    return theString;
    }
    else
    return t_name;
    }