Mon objectif est d'avoir une précharge de l'image pendant le chargement de l'image actuelle, mais je n'arrive pas à la comprendre. Tout l'objectif pour cela est que j'ai un diaporama qui affiche une image, mais parfois il est lent à charger .. lol. Voici mon HTML:préchargement de l'image javascript
<div id="slideshow">
<img src="../images/slideshow/spacer.gif" width="100" height="100" id="myPicture" alt="some image">
</div>
Voici mon javascript je l'ai déjà:
window.onload = choosePic;
function choosePic() {
var myPix = new Array("../images/slideshow/sempiternal.png", "../images/slideshow/cross.png", "../images/slideshow/pentagram.png");
var randomNum = Math.floor((Math.random() * myPix.length));
document.getElementById("myPicture").src = myPix[randomNum];
}
Et le CSS:
#slideshow {
height: 100px;
width: 100px;
position: fixed;
bottom: 20px;
right: 20px;
}
C'est ce que je pensais, mais je voulais voir si quelqu'un d'autre pouvait penser à quelque chose. Merci pour votre temps! –