Posted By

primitiveshaun on 04/15/11


Tagged

basics


Versions (?)

Preload a List of Images


 / Published in: JavaScript
 

Preloads a list of difined images to the browser cache

  1. <!--
  2.  
  3. if (document.images)
  4. {
  5. preload_image_object = new Image();
  6. // set image url
  7. image_url = new Array();
  8. image_url[0] = "http://mydomain.com/image0.gif";
  9. image_url[1] = "http://mydomain.com/image1.gif";
  10. image_url[2] = "http://mydomain.com/image2.gif";
  11. image_url[3] = "http://mydomain.com/image3.gif";
  12.  
  13. var i = 0;
  14. for(i=0; i<=3; i++)
  15. preload_image_object.src = image_url[i];
  16. }
  17.  
  18. //-->

Report this snippet  

You need to login to post a comment.