Jump to content

Preloading images.


bbr

Recommended Posts

Currently using this for the script :its a for loop so it's easy to expand. (saw the example on another site)

var imagenames=new Array('../pics/fullshot_small2.gif');var images=new Array();function loadimages(){  for(n=0;n<imagenames.length;n++)  {    images[n]=new Image();    images[n].src=imagenames[n];    setTimeout('checkload('+n+')' ,n*100);  }}function checkload(index){  (images[index].complete)? dispbars() : setTimeout('checkload('+index+')', 100);}function dispbars(){}window.onload=loadimages;

Which is loaded into the page like this :

<a href="fullshot.htm" onmouseover="document.images['b1'].src='../pics/fullshot_small2.gif'" onmouseout="document.images['b1'].src='../pics/fullshot_small.gif'"><img name="b1" src="../pics/fullshot_small.gif" border="0" width="250" height="330" alt=""></a>

It seems to work fairly good so far.but i'm just curious how other people preload their images.Any better or faster alternatives?

Link to comment
Share on other sites

Doesn't internet explorer grab the image from the source file twice anyway, so preloading in the browser doesn't really have much effect?  I could be wrong.

Could be, but if the mouseover image is loaded by javascript. IE doesn't know it exists until you actually move your cursor there.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...