Thread: Pre-Load Images
View Single Post
  #20 (permalink)  
Old Jun 21st, 2005, 08:27
Webforumz Staff Webforumz Staff is offline
Most Reputable Member
Join Date: Jul 2003
Posts: 1,856
Thanks: 0
Thanked 0 Times in 0 Posts
Try this instead, it's the preloader/rollover script I use for all my sites.

In the HEAD put (and of course put all 23 images in the list)
Code: Select all
<script type="text/css">
CI = new Array()
aryI = String("001_Small.png,002_Small.png,003_Small.png,004_Small.png").split(",")


for (i=0;i<aryI.length;i++) {
	CI[(i*2)] = new Image()
	CI[(i*2)].src = "Pictures/" + aryI[i]
	CI[(i*2+1)] = new Image()
	hname = String(aryI[i]).replace(".","2.")
	CI[(i*2+1)].src = "Pictures/" + hname
}

function menu(ind,bon) {
	eval('document.images["r'+ind+'"].src = CI[' + ((ind*2)-(bon ? 1 : 2)) + '].src')
}
</script>
Then put each image/link in your page like this:
Code: Select all
[img]Pictures/001_Small.png[/img]
Change the numbers in menu(#, and r# using 1 to 23
Reply With Quote