Défilement automatique pour un diaporama

Fermé
Titou - 8 juin 2011 à 15:25
 glopglop - 8 juin 2011 à 16:30
Bonjour,

J'ai pu insérer un code javascript pour un diaporama, cependant celui-ci n'a pas de défilement automatique il faut que le visiteur clique sur "start". Que dois je ajouter à mon code pour que le défilement soit automatique.

Voici le code
Dans le head :


<SCRIPT LANGUAGE="JavaScript">
var rotate_delay = 5000;
current = 0;
function next() {
if (document.slideform.slide[current+1]) {
document.images.show.src = document.slideform.slide[current+1].value;
document.slideform.slide.selectedIndex = ++current;
}
else first();
}
function previous() {
if (current-1 >= 0) {
document.images.show.src = document.slideform.slide[current-1].value;
document.slideform.slide.selectedIndex = --current;
}
else last();
}
function first() {
current = 0;
document.images.show.src = document.slideform.slide[0].value;
document.slideform.slide.selectedIndex = 0;
}
function last() {
current = document.slideform.slide.length-1;
document.images.show.src = document.slideform.slide[current].value;
document.slideform.slide.selectedIndex = current;
}
function ap(text) {
document.slideform.slidebutton.value = (text == "Stop") ? "Start" : "Stop";
rotate();
}
function change() {
current = document.slideform.slide.selectedIndex;
document.images.show.src = document.slideform.slide[current].value;
}
function rotate() {
if (document.slideform.slidebutton.value == "Stop") {
current = (current == document.slideform.slide.length-1) ? 0 : current+1;
document.images.show.src = document.slideform.slide[current].value;
document.slideform.slide.selectedIndex = current;
window.setTimeout("rotate()", rotate_delay);
}
}
// End -->
</script>

Dans le body :

<form name=slideform>
<table cellspacing=1 cellpadding=4 bgcolor="#000000">

<tr>
<td bgcolor="#ffffff" height="250" width="650" align="center"><img name="show" alt="" src="http://www.bebetibou.com/images/m/mon/montage-sleepy-wrap.jpg" /></td>
</tr>
<tr>
<td bgcolor="#c0c0c0" align="center"><select onChange="change();" name="slide">
<option value="image1.jpg"selected="selected">N°1</option>
<option value=" image2.jpg">N°2</option>
<option value=" image3.jpg">N°3</option>
</select></td>
</tr>
<tr>
<td bgcolor="#c0c0c0" align="center"><input title="Beginning" type="button" onClick="first();" value="|<<" /> <input title="Previous" type="button" onClick="previous();" value="<<" /> <input title="AutoPlay" type="button" onClick="ap(this.value);" name="slidebutton" value="Start" /> <input title="Next" type="button" onClick="next();" value=">>" /> <input title="End" type="button" onClick="last();" value=">>|" /></td>
</tr>
</table>
</form>


Merci d'avance.

1 réponse

<body onload="ap('Start')">
0