out of memory 问题

cantalou 2010-04-07 09:59:59

function rotateImage(){
var images = new Array();

for(var i = 0; i<4;i++){
images[i] = new Image();
images[i].src ="image/pic"+i+".jpg";
}
run(1,images);
}
function run(index ,images){
但如果在加alert();查看的时候又可以
window.document.img1.src=images[index].src;
index++;
if(index > 3){
index = 0
}
setTimeout(run(index,images),1000);
}


出现out of memory at line :12
...全文
156 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
hookee 2010-04-08
  • 打赏
  • 举报
回复

var images = new Array();
var index = 1;
var tid;
function rotateImage(){
for(var i = 0; i<4;i++){
images[i] = new Image();
images[i].src ="image/pic"+i+".jpg";
}
run();
}

function run(){
if(tid!=null) clearTimeout(tid);
document.img1.src=images[index].src;
index++;
if(index > 3) index = 0;
tid = setTimeout("run()",1000);
}

wgale025 2010-04-08
  • 打赏
  • 举报
回复
死循环了吧。
KK3K2005 2010-04-08
  • 打赏
  • 举报
回复
setTimeout(run(index,images),1000);

setTimeout(function(){run(index,images)},1000);
cantalou 2010-04-07
  • 打赏
  • 举报
回复
自己顶

87,904

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧