我对 Javascript 不是很有经验,但我遇到了一个我无法理解的问题。我的代码很简单:
document.getElementById ('chat_line_list').addEventListener ("DOMSubtreeModified", LocalMain, false);
function LocalMain ()
{
var chatList = document.getElementById('chat_line_list').lastChild.lastElementChild.innerHTML;
chatList = chatList.replace('InfoThump', '<span class="newemo-1 emoticon"></span>');
chatList = chatList.replace('MuskMelon', '<span class="newemo-2 emoticon"></span>');
chatList = chatList.replace('PoisonApple', '<span class="newemo-3 emoticon"></span>');
chatList = chatList.replace('PoisonBanana', '<span class="newemo-4 emoticon"></span>');
chatList = chatList.replace('PoisonWatermelon', '<span class="newemo-5 emoticon"></span>');
chatList = chatList.replace('PoisonGrape', '<span class="newemo-6 emoticon"></span>');
chatList = chatList.replace('NotNippy', '<span class="newemo-7 emoticon"></span>');
document.getElementById('chat_line_list').lastChild.lastElementChild.innerHTML = chatList;
}
当我用新修改的字符串替换 innerHTML 时,异常发生在 LocalMain() 函数的最后一行。此代码中是否存在导致循环或溢出的内容?