setTimeout 运行完第一次后提示网页上有错误,请回复,谢谢!

来源:百度知道 编辑:UC知道 时间:2024/09/20 22:45:15
<script>

function show(){
var i=prompt("enter the name");
i=i.toLowerCase();
switch (i) {
case "oranges" :
document.write("Oranges are $0.59 a pound.<BR>");
break;
default :
document.write("Sorry, we are out of " + i + ".<BR>");
break;
}
setTimeout('show()',5000);
}

show();
</script>

<script>

function show(){
var i=prompt("enter the name");
i=i.toLowerCase();
switch (i) {
case "oranges" :
document.write("Oranges are $0.59 a pound.<BR>");
break;
default :
document.write("Sorry, we are out of " + i + ".<BR>");
break;
}

}
setTimeout('show()',5000);
</script>
这样放~~大哥 不知道你了解递归调用不。。。你那样写是一个死循环。。。第一次没问题,因为有个5000的时候是空挡,,一但到了时间执行setTimeout('show()',5000); 就会出现死循环 同时也没有获取到对象

document.write 引起的

原因:http://zhidao.baidu.com/question/44710210.html