Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to make an image random but not repeat by modifying this code
    text
    copied!<p>The below code is the only code that worked on my site (built w an online template) alll other javascript crashed. (I am very novice at web programming) Is there a simple change I can make to this code in order to not have a repeat picture till all the pictures were displayed?</p> <pre><code>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&lt;randomimages.length;n++) { preload[n]=new Image() preload[n].src=randomimages[n] } document.write('&lt;img name="defaultimage" src="'+ randomimages[Math.floor(Math.random()*(randomimages.length))]+'"&gt;') 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) </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload