Code pour changer des images
Bonjour,
J'ai un problème avec un code qui va me servir à changer d'images toutes les 2 secondes.
Voici le code en question :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Document sans nom</title>
</head>
<body onload="alterne();">
<img alt="" src="image0.jpg" class="tp_image01">
<script type="text/javascript">
<!--
var img0="images/tp_image01.gif";
var img1="images/tp_image02.gif";
var img2="images/tp_image03.gif";
var img3="images/tp_image04.gif";
var i=0;
function alterne(){
i++;
if (i==6) {i=0}
document.images[0].src=eval("img"+i);
setTimeout("alterne()", 2000); // 2000 est une valeur en millisecondes
}
//-->
</script>
</body>
</html> |
Je l'ai insérer dans ma page mais ca ne marche pas et en plus ca fait beuger la page, pouvez-vous m'aider à insérer ce code correctement ?
Voici comment je l'ai insérer :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| <body onload="alterne();">
<div id="mainblock">
<!--inner block starts here -->
<div id="innerblock">
<div id="toppanel">
<div align="left"><img src="images/tp_logo.gif" width="238" height="54" alt="" class="tp_logo" /> <img src="images/tp_shopping_img.gif" width="13" height="11" alt="" class="tp_shopping_img" /> <a href="http://cosmetiques-aloevera.com/panier.php" class="tp_txt1">Mon panier <br />
0 article(s)</a> <a href="http://cosmetiques-aloevera.com/connexion.php" class="tp_txt2"> Connexion <br />
S'enregistrer</a>
</div>
<div class="tp_menu_tile"> <a href="http://cosmetiques-aloevera.com/index.php" class="tp_menu1">Acceuil</a> <img src="images/tp_divider.gif" width="2" height="39" alt="" class="tp_divider" /> <a href="http://cosmetiques-aloevera.com/nouveautes.php" class="tp_menu2">Nouveautés</a> <img src="images/tp_divider.gif" width="2" height="39" alt="" class="tp_divider" /> <a href="http://cosmetiques-aloevera.com/promos.php" class="tp_menu2">Promos</a> <img src="images/tp_divider.gif" width="2" height="39" alt="" class="tp_divider" /> <a href="http://cosmetiques-aloevera.com/faq.html" class="tp_menu2">FAQ</a> <img src="images/tp_divider.gif" width="2" height="39" alt="" class="tp_divider" /> <a href="http://cosmetiques-aloevera.com/qui-sommes-nous.php" class="tp_menu2">Qui sommes-nous ?</a> <img src="images/tp_divider.gif" width="2" height="39" alt="" class="tp_divider" /> <a href="http://cosmetiques-aloevera.com/blog.php" class="tp_menu2">Blog</a> </div>
<div class="tp_tile2"> <img src="images/tp_btn1.gif" width="15" height="15" alt="" class="tp_btn1" />
<p class="tp_heading">À Découvrir</p>
</div>
<div class="tp_block">
<img alt="" src="images/tp_image01.gif" width="140" height="135" class="tp_image01">
<script type="text/javascript">
<!--
var img0="images/tp_image05.gif";
var img1="images/tp_image06.gif";
var img2="images/tp_image07.gif";
var i=0;
function alterne(){
i++;
if (i==6) {i=0}
document.images[0].src=eval("img"+i);
setTimeout("alterne()", 2000); // 2000 est une valeur en millisecondes
}
//-->
</script>
</div> |
Je vous remercie d'avance.