Preloading multiple images using single function
by Nirmala[ Edit ] 2009-05-20 16:59:32
Hi...
In our webpage having more images means that takes lot of times to load all images. To overcome this issue use the below code.
<script type="text/javascript>
function preload()
{
var args=preload.arguments;
document.imageArray=new Array(args.length);
for(var i=0;i<args.length;i++)
{
document.imageArray[i]=new Image;
document.imageArray[i].src=args[i];
}
}
</script>
Call the
preload() function.
<body onload="preload('img1.gif','img2.gif',...)">