Besoin d'aide pour un javascript....
eexell
-
PhP -
PhP -
Voici un script pour un diaporama photo...le diaporama commence dès l'ouverture de la page et tourne en boucle.
Je voudrais savoir ce que je dois modifier ou rajouter pour qu'il ne démarre pas tout seul, mais qu'on soit obligé de clicker sur la première image pour démarrer l'animation. ET aussi ce qu'il faut faire pour qu'il ne tourne pas en boucle mais s'arrête a la dernière image....
Merci d'avance
xl
============================================
<html>
<head>
<SCRIPT LANGUAGE="JavaScript">
<!--
var timeDelay = 3;
var Pix = new Array
("photos/peep1.jpg"
,"photos/peep2.jpg"
,"photos/peep3.jpg"
,"photos/peep4.jpg"
,"photos/peep5.jpg"
,"photos/peep6.jpg"
,"photos/peep7.jpg"
,"photos/peep8.jpg"
);
var howMany = Pix.length;
timeDelay *= 1000;
var PicCurrentNum = 0;
var PicCurrent = new Image();
PicCurrent.src = Pix[PicCurrentNum];
function startPix() {
setInterval("slideshow()", timeDelay);
}
function slideshow() {
PicCurrentNum++;
if (PicCurrentNum == howMany) {
PicCurrentNum = 0;
}
PicCurrent.src = Pix[PicCurrentNum];
document["ChangingPix"].src = PicCurrent.src;
}
// End -->
</script>
</head>
<body bgcolor="#000000" text="#ffffff" link="#000000" vlink="#000000" alink="#000000" onload="startPix()"><br>
<br>
<br>
<center><img name="ChangingPix" src="mon_image_01.jpg"></center>
</body>
</html>
Je voudrais savoir ce que je dois modifier ou rajouter pour qu'il ne démarre pas tout seul, mais qu'on soit obligé de clicker sur la première image pour démarrer l'animation. ET aussi ce qu'il faut faire pour qu'il ne tourne pas en boucle mais s'arrête a la dernière image....
Merci d'avance
xl
============================================
<html>
<head>
<SCRIPT LANGUAGE="JavaScript">
<!--
var timeDelay = 3;
var Pix = new Array
("photos/peep1.jpg"
,"photos/peep2.jpg"
,"photos/peep3.jpg"
,"photos/peep4.jpg"
,"photos/peep5.jpg"
,"photos/peep6.jpg"
,"photos/peep7.jpg"
,"photos/peep8.jpg"
);
var howMany = Pix.length;
timeDelay *= 1000;
var PicCurrentNum = 0;
var PicCurrent = new Image();
PicCurrent.src = Pix[PicCurrentNum];
function startPix() {
setInterval("slideshow()", timeDelay);
}
function slideshow() {
PicCurrentNum++;
if (PicCurrentNum == howMany) {
PicCurrentNum = 0;
}
PicCurrent.src = Pix[PicCurrentNum];
document["ChangingPix"].src = PicCurrent.src;
}
// End -->
</script>
</head>
<body bgcolor="#000000" text="#ffffff" link="#000000" vlink="#000000" alink="#000000" onload="startPix()"><br>
<br>
<br>
<center><img name="ChangingPix" src="mon_image_01.jpg"></center>
</body>
</html>
A voir également:
- Besoin d'aide pour un javascript....
- Telecharger javascript pour pc - Télécharger - Langages
- A javascript error occurred in the main process - Forum Windows
- Javascript void 0 c'est quoi ✓ - Forum Réseaux sociaux
- Javascript arrondi - Forum Javascript
- Javascript arrondir à 2 décimales - Forum Webmastering
2 réponses
Salut XL
Voici le script modifié (sans erreur j'espère :) )
<html>
<head>
<SCRIPT LANGUAGE="JavaScript">
<!--
var start=false;
var timeDelay = 3;
var Pix = new Array
("photos/peep1.jpg"
,"photos/peep2.jpg"
,"photos/peep3.jpg"
,"photos/peep4.jpg"
,"photos/peep5.jpg"
,"photos/peep6.jpg"
,"photos/peep7.jpg"
,"photos/peep8.jpg"
);
var howMany = Pix.length;
timeDelay *= 1000;
var PicCurrentNum = 0;
var PicCurrent = new Image();
PicCurrent.src = Pix[PicCurrentNum];
function startPix() {
if (!start)
{
setTimeout("slideshow()", timeDelay);
start=true; // Evite de relancer startPix si l'utilisateur clic pls fois
}
}
function slideshow() {
PicCurrentNum++;
if (PicCurrentNum < howMany) {
PicCurrent.src = Pix[PicCurrentNum];
document["ChangingPix"].src = PicCurrent.src;
if ((PicCurrentNum+1) < howMany) setTimeout("slideshow()", timeDelay);
}
}
// End -->
</script>
</head>
<body bgcolor="#000000" text="#ffffff" link="#000000" vlink="#000000" alink="#000000" onload="startPix()"><br>
<br>
<br>
<center><img name="ChangingPix" src="mon_image_01.jpg" onclick="startPix() "></center>
</body>
</html>
Voilà ca devrait suffire
@+
Philippe
Voici le script modifié (sans erreur j'espère :) )
<html>
<head>
<SCRIPT LANGUAGE="JavaScript">
<!--
var start=false;
var timeDelay = 3;
var Pix = new Array
("photos/peep1.jpg"
,"photos/peep2.jpg"
,"photos/peep3.jpg"
,"photos/peep4.jpg"
,"photos/peep5.jpg"
,"photos/peep6.jpg"
,"photos/peep7.jpg"
,"photos/peep8.jpg"
);
var howMany = Pix.length;
timeDelay *= 1000;
var PicCurrentNum = 0;
var PicCurrent = new Image();
PicCurrent.src = Pix[PicCurrentNum];
function startPix() {
if (!start)
{
setTimeout("slideshow()", timeDelay);
start=true; // Evite de relancer startPix si l'utilisateur clic pls fois
}
}
function slideshow() {
PicCurrentNum++;
if (PicCurrentNum < howMany) {
PicCurrent.src = Pix[PicCurrentNum];
document["ChangingPix"].src = PicCurrent.src;
if ((PicCurrentNum+1) < howMany) setTimeout("slideshow()", timeDelay);
}
}
// End -->
</script>
</head>
<body bgcolor="#000000" text="#ffffff" link="#000000" vlink="#000000" alink="#000000" onload="startPix()"><br>
<br>
<br>
<center><img name="ChangingPix" src="mon_image_01.jpg" onclick="startPix() "></center>
</body>
</html>
Voilà ca devrait suffire
@+
Philippe