views:

67

answers:

1

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.

+1  A: 

Take a look at http://elouai.com/javascript-preload-images.php, hope it'll help.

Mushex Antaranian