Jump to content

Preloading Images for Slide SHow


jakester
 Share

Recommended Posts

I have this slide show for various stuff we sell. We have these 8 jpegs, so in order to save bandwith, I created an array of Image objects so the jpegs get cached and the browser won't keep downloading the pictures. The code works faultlessly but it still shows in the IE status bar each time the jpeg changes that the same jpegs are being downloaded from the server instead of using the cache.

		  <script language="JavaScript">var x = 0;var pics = new Array(8);var imageObj =  new Array(8);var ItemUrl = new Array(8);var ItemName = new Array(8);var blurb = new Array(8);function switchpics(){document.specialPics.src =  imageObj[x].src;document.specialPics.alt = ItemName[x];document.getElementById('specialLink1').href =  ItemUrl[x];document.getElementById('specialLink2').href =  ItemUrl[x];document.getElementById('specialName').innerHTML =  ItemName[x] + '<br />' + blurb[x];if(x < (8-1))x++;else x = 0; return;}imageObj[0] = new Image();imageObj[0].src = './Products/mrqa/mrqa180.jpg';document.emptyImage.src  = './Products/mrqa/mrqa180.jpg';ItemUrl[0] = '/common_index/chock/chock.php?sn=22113';ItemName[0] = 'RPA  Large Rubber Pyramid<br />Three Cavity with Eye Bolt';blurb[0] = 'Grade A - 3 Cavity Rubber Extruded Chock';imageObj[1] = new Image();imageObj[1].src = './Products/hgs/hgs_180.jpg';document.emptyImage.src  = './Products/hgs/hgs_180.jpg';ItemUrl[1] = '/common_index/chock/chock.php?sn=12103';ItemName[1] = 'HGS Large Aluminum Chock<br />Molded Heavy Gripper Standard';blurb[1] = 'High performance "Gripper Standard"';imageObj[2] = new Image();imageObj[2].src = './Products/hwc7/hwc7_180.jpg';document.emptyImage.src  = './Products/hwc7/hwc7_180.jpg';ItemUrl[2] = '/common_index/chock/chock.php?sn=11101';ItemName[2] = 'HWC7 Large Aluminum Wheel Chock<br />Extruded with Solid Bottom';blurb[2] = 'A heavy duty chock suited to Wildlands application';imageObj[3] = new Image();imageObj[3].src = './Products/hrg/hrg180.jpg';document.emptyImage.src  = './Products/hrg/hrg180.jpg';ItemUrl[3] = '/common_index/chock/chock.php?sn=21101';ItemName[3] = 'HRG -Large Rubber Contour<br />High Density';blurb[3] = 'Heavy Rubber Chock';imageObj[4] = new Image();imageObj[4].src = './Products/rwl/rwl_180.jpg';document.emptyImage.src  = './Products/rwl/rwl_180.jpg';ItemUrl[4] = '/common_index/chock/chock.php?sn=23214';ItemName[4] = 'RWL    Medium Rubber Chock<br />Extruded EPDM Wedge';blurb[4] = 'Good for paper rolls in mills';imageObj[5] = new Image();imageObj[5].src = './Products/arg12/arg12_180.jpg';document.emptyImage.src  = './Products/arg12/arg12_180.jpg';ItemUrl[5] = '/common_index/chock/chock.php?sn=3121200002';ItemName[5] = 'ARG12 Large Aircraft Chock<br />Extruded SBR Rubber';blurb[5] = 'The ARG12 large aircraft chock is a durable extruded SBR rubber chock.';imageObj[6] = new Image();imageObj[6].src = './Products/arc_4h/arc4h_180.jpg';document.emptyImage.src  = './Products/arc_4h/arc4h_180.jpg';ItemUrl[6] = '/common_index/chock/chock.php?sn=31904';ItemName[6] = 'A-4H Small Aircraft Chock';blurb[6] = 'A small Extruded Rubber Chock for Nose wheels, etc';imageObj[7] = new Image();imageObj[7].src = './Products/oum/oum_180.jpg';document.emptyImage.src  = './Products/oum/oum_180.jpg';ItemUrl[7] = '/common_index/chock/chock.php?sn=41002';ItemName[7] = 'OUM Mega Urethane Chock<br />Hi-Vis Orange with Pass Through';blurb[7] = 'Huge chock for mine trucks, up to 240 tons, bright orange';setInterval("switchpics()", 15000);</script>

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
 Share

×
×
  • Create New...