<div class="codetitle"> <span><a style="CURSOR: pointer" data="6043" class="copybut" id="copybut6043" onclick="doCopy('code6043')"><u>複製程式碼</u></a></span>程式碼如下:</div> <div class="codebody" id="code6043"> <br><script type="text/javascript" src="http:%20/%20/ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">腳本> <br><br><腳本> <BR>(function($){ <BR>$ .extend($,{ <BR>fixedWidth:function(str,length,char){ <BR>str=str.toString(); <BR>if(! char) char="..."; <BR> var num=length-lengthB(str) <BR>if(num<0){ <BR>str=substringB(str,length-lengthB(char)) char ; <BR>} <BR>回傳str <BR>函數substringB(str,length){ <BR>var num=0,len=str.length,tenp=""; <BR>if(len){ <BR>for(var i=0;i<len;i ) { <BR>if(num>length) <BR>if(str.charCodeAt(i)>255){ <BR>num =2; <BR>tenp =str.charAt(i) <BR>} else{ <BR>num ; <BR>tenp =str.charAt(i) <BR>} <BR>回傳tenp <BR>}else{ <BR>回傳null; >函數lengthB(str){ <BR>var num=0 ,len=str.length; <BR>for(var i=0;i<len;i ){ <BR>if(str.charCodeAt(i)> 255){ <BR>num =2 <BR>}else { <BR>num; <BR>} <BR>回傳num; <BR>}其他{ <BR>回傳0; } <BR>} <BR>}); (jQuery); <BR>var a=" abcde我是誰?</script> </div>