下面的代码是在我的网站上工作的唯一代码(使用在线模板构建)所有其他 javascript 都崩溃了。(我在网络编程方面非常新手)我可以对此代码进行简单的更改,以便在显示所有图片之前没有重复图片?
var delay=7000 //set delay in miliseconds
var curindex=0
var randomimages=new Array()
randomimages[0]="content/indsidebar1(2).jpg"
randomimages[1]="content/indsidebar2.jpg"
randomimages[2]="content/indsidebar3(3).jpg"
randomimages[3]="content/indsidebar6a.jpg"
randomimages[4]="content/indsidebar5.jpg"
randomimages[5]="content/indsidebar6.jpg"
randomimages[6]="content/indsidebar7.jpg"
randomimages[7]="content/indsidebar8.jpg"
randomimages[8]="content/indsidebar9.jpg"
randomimages[9]="content/indsidebar10.JPG"
randomimages[10]="content/commersidebar1.JPG"
randomimages[11]="content/commersidebar2.JPG"
randomimages[12]="content/commersidebar4.JPG"
randomimages[13]="content/commersidebar5.JPG"
randomimages[14]="content/commersidebar6.JPG"
randomimages[15]="content/commersidebar7.JPG"
randomimages[16]="content/ressidebar1.JPG"
randomimages[17]="content/ressidebar2.JPG"
randomimages[18]="content/ressidebar3.JPG"
randomimages[19]="content/ressidebar4.JPG"
randomimages[20]="content/communsidebar1.JPG"
randomimages[21]="content/communsidebar3.JPG"
randomimages[22]="content/communsidebar4.JPG"
randomimages[23]="content/communsidebar5.JPG"
randomimages[24]="content/communsidebar6.JPG"
randomimages[25]="content/communsidebar7.JPG"
randomimages[26]="content/communsidebar8.JPG"
randomimages[27]="content/communsidebar10.JPG"
randomimages[28]="content/undersidebar1.jpg"
randomimages[29]="content/undersidebar2(1).jpg"
randomimages[30]="content/undersidebar3.jpg"
randomimages[31]="content/undersidebar4.jpg"
randomimages[32]="content/servicesidebar1.jpg"
randomimages[33]="content/servicesidebar2.jpg"
randomimages[34]="content/servicesidebar6.jpg"
randomimages[35]="content/servicesidebar4.JPG"
randomimages[36]="content/servicesidebar5.JPG"
var preload=new Array()
for (n=0;n<randomimages.length;n++)
{
preload[n]=new Image()
preload[n].src=randomimages[n]
}
document.write('<img name="defaultimage" src="'+
randomimages[Math.floor(Math.random()*(randomimages.length))]+'">')
function rotateimage()
{
if (curindex==(tempindex=Math.floor(Math.random()*(randomimages.length))))
curindex=curindex==0? 1 : curindex-1
else
curindex=tempindex
document.images.defaultimage.src=randomimages[curindex]
}
setInterval("rotateimage()",delay)