Jump to content
xisto Community
Sign in to follow this  
kvarnerexpress

Banner From Single To Random

Recommended Posts

I've got a banner that has a single image background in the CSS and it fades in but I'd like to set it up so it actually loaded an array of images. That is 'if' its possible so the users without JavaScript enabled still get the original image. Is this at all possible?The original code is belowcode:--------------------------------------------------------------------------------function initImage() { imageId = 'loader'; image = document.getElementById(imageId); setOpacity(image, 0); image.style.visibility = "visible"; fadeIn(imageId,0);}function fadeIn(objId,opacity) { if (document.getElementById) { obj = document.getElementById(objId); if (opacity <= 100) { setOpacity(obj, opacity); opacity += 10; window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 100); } }}function setOpacity(obj, opacity) { opacity = (opacity == 100)?99.999:opacity; // IE/Win obj.style.filter = "alpha(opacity:"+opacity+")"; // Safari<1.2, Konqueror obj.style.KHTMLOpacity = opacity/100; // Older Mozilla and Firefox obj.style.MozOpacity = opacity/100; // Safari 1.2, newer Firefox and Mozilla, CSS3 obj.style.opacity = opacity/100;}window.onload = function() { initImage();}# now if I put images into an array like (without the hashes of course)##var pics = new Array(3); // Change this to reflext the number of ##slides##var num = 0;##var totalPics = 2; // 3 slides numbered 0 to 2// Command to preload the images into the array##for (num = 0; num <= totalPics; num++) {## pics[num] = new Image();## pics[num].src = "graphics/pic" + num + ".jpg";##}--------------------------------------------------------------------------------

Share this post


Link to post
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
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.