javascript slideshow bug after several iterations -


i created own picture scroll in javascript , after 3 -4 photo change script crashes page. not know why! if can me? pictures taken randomly 2 differents files, , stock them on array

here code:

 <div class="corpshaut">  <a href="" id="lien_banniere0" border="0" class="image-bandeau"><img src="" id="banniere0" height="150" border="0" width="150" /></a>  <a href="" id="lien_banniere1" border="0" class="image-bandeau"><img src="" id="banniere1" height="150" border="0" width="150"/></a>  <a href="" id="lien_banniere2" border="0" class="image-bandeau"><img src="" id="banniere2" height="150" border="0" width="150"/></a>  <a href="" id="lien_banniere3" border="0" class="image-bandeau"><img src="" id="banniere3" height="150" border="0" width="150"/></a>  <a href="" id="lien_banniere4" border="0" class="image-bandeau"><img src="" id="banniere4" height="150" border="0" width="150"/></a>  <script>  $(document).ready(function(){  boucle();  });  function boucle(){  /*variablde de parametre*/  var nbimagetotal = 5;  var nbimagesuivie = 1;  var nbimagedossier = 11;  var repertoire = 'image3/(';  var lien = 'www.lien.fr';  /*-------------------------*/  /*variablde*/  var stock = new array();  var index;  var occu;  var nbimage = math.floor((math.random()*nbimagetotal)+1);  var aleatoire;  /*-------------------------*/  while (nbimagesuivie <= nbimagetotal){  occu=0;  (i=0; i<nbimage; i++){  aleatoire = repertoire + math.floor((math.random()*nbimagedossier)+1) + ').gif';  /*boucle permettant de verifier si l'image est déja dans le tableau*/  (j =0; j<i;j++){  index= stock[j].indexof(aleatoire);  if (index != -1) {  occu=1;  }  }  if (occu==0) {  stock[i] = new array();  stock[i][0]= aleatoire;  stock[i][1]=lien;  nbimagesuivie = nbimagesuivie +1;  }  else{  --i;  }  }  if(nbimage < 5){  occu=0;  var repertoire2 = 'image2/';  var nbimagedossier2 = 11;  var nbimage2 = nbimagetotal - nbimage;  var lien2 = 'www.lien2.fr' ;  (i=nbimage; i<nbimagetotal; i++){  aleatoire = repertoire2 + math.floor((math.random()*nbimagedossier)+1) + '.jpg';  /*boucle permettant de verifier si l'image est déja dans le tableau*/  (j =0; j<i;j++){  index= stock[j].indexof(aleatoire);  if (index != -1) {  occu=1;  }  }  if (occu==0) {  stock[i] = new array();  stock[i][0]= aleatoire;  stock[i][1]=lien2;  nbimagesuivie = nbimagesuivie +1;  }  else{  --i;  }  }    }  }  (i=0;i<nbimagetotal;i++){  $('#lien_banniere'+i).attr('href', stock[i][1]);  $('#banniere'+i).attr('src',stock[i][0] );  }  settimeout(function(){boucle()}, 5000);  }  </script> 

thx help

you have infinite loop because if occu==1 you're doing --i, i++ , loop continue way without breaking.


Comments