作者TonyQ (骨頭)
看板Ajax
標題Re: [問題] ajax函式化回傳數值
時間Fri Apr 6 12:58:48 2007
※ 引述《TonyQ (骨頭)》之銘言:
1F:推 ayuiop:請問為何需要parseInt(escape(valueObj[i]).length) 04/05 13:31
2F:→ ayuiop:而不直接取用length就好? 04/05 13:32
主要是針對於中文字上的處理,escape後會改變文章長度,
底下這段code應該可以敘述一些事情。
function go(){
var word="哈囉";
msg(word + "_" +word.length);
msg(escape(word)+"_"+escape(word).length);
}
function msg(str){
document.getElementById('msg').innerHTML+="<br />"+str;
}
這是執行結果
哈囉_2
%u54C8%u56C9_12
--
String temp="relax"; | Life just like programing
while(buringlife) String.forgot(temp); | to be right or wrong
while(sleeping) brain.setMemoryOut(); | need not to say
stack.push(life.running); | the compiler will
stack.push(scouting.buck()); | answer your life
stack.push(bowling.practice()); | Bone
everything
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 220.134.27.68
3F:推 ayuiop:抱歉我沒講清楚,我的意思是為什麼需要parseInt? 04/06 13:58
4F:推 TonyQ:哦 那個不用理它 ̄▽ ̄ 我只是怕發生 1+1 = 11的慘案而已 04/06 18:55
5F:推 ayuiop:喔喔XD 04/06 21:59