私の目標は、実際の画像を読み込んでいる間に画像をプリロードすることですが、よくわかりません。これの全体的な目標は、画像を表示するスライドショーを作成することですが、読み込みが遅い場合があります..笑。ここに私のHTMLがあります:
<div id="slideshow">
<img src="../images/slideshow/spacer.gif" width="100" height="100" id="myPicture" alt="some image">
</div>
ここに私がすでに持っている私のjavascriptがあります:
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];
}
そしてCSS:
#slideshow {
height: 100px;
width: 100px;
position: fixed;
bottom: 20px;
right: 20px;
}