简体   繁体   中英

Javascript Array Pre-load

I have this small javascript code and that makes a manual slideshow, but it requires every image to be downloaded before displaying. Could anyone please modify my code so that it preloads all the images (in order) and eliminates that annoyance.

JS Code:

var pos = 0;
var imgs = new Array('1.png', '2.png', '3.png');
document.write("<img src=\"" + imgs[0] + "\" onclick=\"(pos+1>imgs.length-1)?pos=0:++pos; this.src=imgs[pos]\" />");


Help much appreciated.

看看http://elouai.com/javascript-preload-images.php ,希望对您有所帮助。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM