运行此命令时,我的网页崩溃了:
function replace()
{
var str = document.getElementById('feeds');
var cont = str.innerHTML;
curstring = "twitter: ";
while (cont.indexOf(curstring))
{
replaced = cont.replace(curstring,"TWIMG ");
str.innerHTML = replaced;
}
}
最佳答案
就在这里。您永远不会重新分配续。也许试试这个?
function replace()
{
var str = document.getElementById('feeds');
var cont = str.innerHTML;
curstring = "twitter: ";
while (cont.indexOf(curstring) != -1)
{
replaced = cont.replace(curstring,"TWIMG ");
str.innerHTML = replaced;
cont = str.innerHTML;
}
}
关于javascript - 我的代码中有无限循环吗?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/7216245/