作者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