javascript挂起浏览器

T.T*_*.T. 1 javascript browser

xmlDoc.load("cd_catalog.xml")

var cd=xmlDoc.getElementsByTagName("CD");
var id_set=1;
var id=xmlDoc.getElementsByTagName("ID"+id_set);

i=0;

function next()
{
if (i<id.length-1)
  {
  i++;
  display();

  }
}


function display()
{
document.write('<div class="dd">')
        document.write('<div class="blue" style="WIDTH:')
        document.write(cd[0].getElementsByTagName("ID"+id_set)[i].childNodes[0].nodeValue)
        document.write('"></div>')

document.write('</div>')

}


}
</script>

    <script type="text/javascript"> display()   </script>


    <br><input type="button" onclick="next()" value="next" ID="Button2" NAME="Button2"/>
Run Code Online (Sandbox Code Playgroud)

我看到了相关的问题,但不确定是否有帮助..我添加了next()函数,浏览器挂起,好像它正在加载一些东西,从来没有.如果没有next()调用,显示功能将起作用.我试图做一个变化的这个.

Row*_*wan 5

相关queston 确实帮助.document.write()文档加载完成后无法使用.请参阅有关如何更换的其他问题的答案document.write().