2 Replies - 286 Views - Last Post: 06 September 2008 - 12:18 PM

#1 ahmad_511   User is offline

  • MSX
  • member icon

Reputation: 131
  • View blog
  • Posts: 722
  • Joined: 28-April 07

Images Preloader

Posted 22 May 2007 - 06:12 PM

Description: on body load event
call the function preloadimages('image folder path','image1.gif,image2.png,image3.jpg,....')

on HTML body assign an ID attribute (for any element accepts innerText attribute) to "viewbox" as valuePreload your images for fast browsing
// preloading images for fast browsing
function preloadimages(folder,imagesarray){
viewbox.innerText="Loading Pictures...Please wait"// showing a start loading message
ob=imagesarray.split(",")// spliting the images argument to array of images names
imagescount=ob.length// reading images count
for (t=0;t<=ob.length;t++){// start looping
newimage=new Image()// creating image object
//Add onload event for checking when loading complete and showing this in the vewbox
newimage.onload=function(){viewbox.innerText="image: '"+ob[t]+"' was loaded";imagescount--;if (imagescount==0)viewbox.innerText=""}
newimage.src=folder+"/"+ob[t]// loading the images
}
}


Is This A Good Question/Topic? 0
  • +

Replies To: Images Preloader

#2 huzi8t9   User is offline

  • D.I.C Regular
  • member icon

Reputation: 25
  • View blog
  • Posts: 373
  • Joined: 11-July 07

Re: Images Preloader

Posted 05 September 2008 - 04:17 AM

That's a pretty cool script but I use images to build my site's design.. I don't really want to have to type out all the image names..
Was This Post Helpful? 0
  • +
  • -

#3 ahmad_511   User is offline

  • MSX
  • member icon

Reputation: 131
  • View blog
  • Posts: 722
  • Joined: 28-April 07

Re: Images Preloader

Posted 06 September 2008 - 12:18 PM

thanks for your comment, you can simply delete the part where we asigned a value to the viewbox (viewbox.innerText="blah blah blah" I hope it helps
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1