0

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

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.