Re: [問題] 新手....字串的問題
※ 引述《Toge (就爭一口氣)》之銘言:
: function(responseDetails) {
: var replacements, regex, key, textnodes, node, s;
: var parser = new DOMParser();
: var dom = parser.parseFromString
: (responseDetails.responseText,
: "application/xml");
: var entries = dom.getElementsByTagName('Msg');
: var title;
: var title2;
: for (var i = 0; i < entries.length; i++) {
: title = entries[i].getElementsByTagName
: ('Name')[0].textContent;
: title2 = entries[i].getElementsByTagName
: ('TName')[0].textContent;
: replacements = {title : title2};
用Object取代吧
var replacements=new Object();
replacements[title]=title2;
諸如此類的
總之就不要用 {title:title2} 的方式 XD
: regex = {};
: for (key in replacements) {
: regex[key] = new RegExp(key, 'g');
你在這裡alert(key +"-" + replacements[key]);
應該就會知道原因了
: }
: textnodes = document.evaluate( "//body//text()",
: document, null,
: XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
: for (var j = 0; j < textnodes.snapshotLength; j++) {
: node = textnodes.snapshotItem(j);
: s = node.data;
: for (key in replacements) {
: s = s.replace(regex[key], replacements[key]);
--
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 complier will
stack.push(scouting.buck()); | answer your life
stack.push(bowling.practice()); | Bone everything
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 220.134.27.68
※ 編輯: TonyQ 來自: 220.134.27.68 (03/03 19:09)
推
03/03 20:23, , 1F
03/03 20:23, 1F
推
03/03 20:27, , 2F
03/03 20:27, 2F
推
03/03 21:03, , 3F
03/03 21:03, 3F
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 2 篇):
Ajax 近期熱門文章
PTT數位生活區 即時熱門文章