日期:2014-05-17 浏览次数:20634 次
<script language="javascript" runat="server" > function textCounter(field,maxleng){ var j=0; var newStr = ''; for(var i =0;i <field.length;i ++){ if(field.substr(i,1).charCodeAt() > 255){ j += 2; }else{ j ++; } if(j > maxleng){ newStr = field.substring(0,i); break; }else{ newStr = field; } } return newStr; } </script> <% Dim str:str="wjiwjr rerjewjjfefefjfeiwfewifefewfewifeiisfewffdsfdsf" Response.Write textCounter(str,10)&"..." %>