或: < body onload =" setTimeout(''randPic2()'',3000); randPic1();" > - Evertjan。荷兰。(请将我的电子邮件地址中的x'更改为点数) 谢谢。我尝试了这两个选项并且它们有效但除了两个图像同时旋转的某些点(这是我们试图避免的)。你知道一种防止这种情况发生的方法吗? 让每个人安排另一个人改变,而不是安排 本身改变。 - I am using setTimeout( ) to continuously call a function that randomlyrotates/displays 2 images on a page. The part I need help with is thesecond image should rotate 3 seconds after the first image rotates. Icannot figure out how to accomplish the 3 second delay. My code ispasted below:function randPic(){randPic1();randPic2();}function randPic1(){picIndex = picIndex + 1;if (picIndex>=middlepics.length)picIndex = 0;d.images["pic1"].src="images/middle/"+middlepics[picIndex];d.images["pic1"].alt=middlealts[picIndex];timerID=setTimeout("randPic1()",3700);}function randPic2(){bottomPicIndex = bottomPicIndex + 1;if (bottomPicIndex>=bottompics.length)bottomPicIndex = 0;d.images["pic2"].src="images/bottom/"+bottompics[bottomPicIndex];d.images["pic2"].alt=bottomalts[bottomPicIndex];timerID=setTimeout("randPic2()",5500);}The randPic( ) function is called in the onLoad event of the body tag.Any ideas you may have would be greatly appreciated. 解决方案function randPic(){randPic1();setTimeout(''randPic2()'',3000);}<body onload="randPic();">or:<body onload="setTimeout(''randPic2()'',3000);randPic1();" >--Evertjan.The Netherlands.(Please change the x''es to dots in my emailaddress)function randPic(){ randPic1(); setTimeout(''randPic2()'',3000); }<body onload="randPic();">or:<body onload="setTimeout(''randPic2()'',3000);randPic1();" >--Evertjan.The Netherlands.(Please change the x''es to dots in my emailaddress)Thanks. I tried both of these options and they worked except there issome point at which both images rotate at the same time (which is whatwe are trying to avoid). Do you know of a way to prevent this fromhappening?--Nikki function randPic(){ randPic1(); setTimeout(''randPic2()'',3000); }<body onload="randPic();">or:<body onload="setTimeout(''randPic2()'',3000);randPic1();" >--Evertjan.The Netherlands.(Please change the x''es to dots in my emailaddress) Thanks. I tried both of these options and they worked except there issome point at which both images rotate at the same time (which is whatwe are trying to avoid). Do you know of a way to prevent this fromhappening?Have each one schedule the other to change, instead of schedulingitself to change.-- 这篇关于setTimeout()javascript问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!