Preloading multiple images using single function - Javascript Views : 861
Tagged in : Javascript
2 0
Send mail
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',...)">
By Nirmala, On - 2009-05-20



    Login to add Comments .