View Full Version : Random Image Not Working


Radiant_Stacie_Fan
06-05-2006, 01:40 AM
I found a code that would show one of the two banners I made randomly. Like, you go to my site and see one banner and then you click "refresh" or come again later and it's the second banner.
Anyway, the code isn't working for my site and I don't know why. Maybe this isn't even the right code since it's for Xanga. *shrugs* What code can I use that will actually work, if this won't?

Here's my code:


<!-- start code provided by createblog.com -->
<script type='text/javascript'>
// random banner/image on every visit by micron
// for more xanga scripts and help go to createblog.com

var image = new Array();

// change this to reflect your set of banners
image[0] = 'http://server6.theimagehosting.com/image.php?img=banner_red1m.jpg'
;
image[1] = 'http://server6.theimagehosting.com/image.php?img=banner_red2m.jpg'
;
var index = Math.floor(Math.random() * image.length);
document.write('<img src='+ ((index == image.length) ? image[image.length-1] : image[index]) +'>');
</script>

amyaurora
06-05-2006, 03:25 AM
I looked at the code on the site and it appears at first glance it does look like you copyed it right. So my only question is did you get it between the <head></head> tags like it says?

If so and there is still a problem then I suggest another script like one from http://www.javascriptkit.com

PLus this is the correct url to the images:

http://images6.theimagehosting.com/banner_red1m.jpg

http://images6.theimagehosting.com/banner_red2m.jpg

Fixing those may work as well.

Radiant_Stacie_Fan
06-05-2006, 03:13 PM
ok, thanks.

amyaurora
06-05-2006, 03:18 PM
You're welcome.