Aide en changement d'images en javascript
Résolu
natasha
-
natasha -
natasha -
Bonjour,
j'ai crée un script qui change les images après 3 secondes mais ça marche pas même logiquement tous s'apparait normal voici le code
<script type="text/javascript">
function godiapo()
{
var images = new Array("2.jpg","3.jpg","4.jpg");
var photo = document.getElementById('pico');
for(var i = 0; i<images.length; i++)
{
setTimeout(function (){
photo.src = images[i];},3000);
}
}
</script>
</head>
<body onload="godiapo()">
<img src="2.jpg" width="300" height="200" id="pico"/>
</body>
</html>
Merci
j'ai crée un script qui change les images après 3 secondes mais ça marche pas même logiquement tous s'apparait normal voici le code
<script type="text/javascript">
function godiapo()
{
var images = new Array("2.jpg","3.jpg","4.jpg");
var photo = document.getElementById('pico');
for(var i = 0; i<images.length; i++)
{
setTimeout(function (){
photo.src = images[i];},3000);
}
}
</script>
</head>
<body onload="godiapo()">
<img src="2.jpg" width="300" height="200" id="pico"/>
</body>
</html>
Merci
A voir également:
- Aide en changement d'images en javascript
- Changement dns - Guide
- Changer clavier qwerty en azerty - Guide
- Des images - Guide
- Changement d'heure - Guide
- Changement d'écriture facebook - Guide
j'ai trouvé une astuce
<script type="text/javascript">
var images=new Array("1.jpg","2.jpg","3.jpg","4.jpg");
var i=0;
function changeimages()
{
document.getElementById("ima").src=images[i];
i++;
if(i>=images.length) i=0;
setTimeout("changeimages()",3000);
}
</script>
</head>
<body onload="changeimages()">
<img src="" width="300" height="200" id="ima"/>
</body>