Tuesday, April 5, 2011

Random banner only displaying the first image.

I have an external javascript that contains:

function random_imglink(){  
var myimages=new Array()  
myimages[1]="http://sevir.sitegoz.com/jchs/Banner1.png"
myimages[2]="http://sevir.sitegoz.com/jchs/banner2.png"
myimages[3]="http://sevir.sitegoz.com/jchs/banner3.png"
myimages[4]="http://sevir.sitegoz.com/jchs/banner4.png"
myimages[5]="http://sevir.sitegoz.com/jchs/banner5.png"
myimages[6]="http://sevir.sitegoz.com/jchs/banner6.png"

var ry=Math.floor(Math.random()*myimages.length)
if (ry==0)
ry=1
document.write('<img src="'+myimages[ry]+'" border=0>')
}

And my html contains:

<script language="JavaScript">
<!--
random_imglink()
//-->
</script>

But only the first image loads.
My site is here, the banner is supposed to change every time any of the pages loads (or reloads) but only the first image shows up, any ideas?

From stackoverflow
  • Apache servers are case sensitive. You have "Banner1" capitalized, but none of the other banners. When I try to navigate to the other images (with a lower case 'b'), I am redirected to the hosting site - telling me the file names do not exist.

    This may not be why you aren't getting the other images, but it certainly isn't helping.

    Re0sless : looks like this is the problem as the img url changes every time I try and load the page, but the image is missing, capitalising the B make the url work ok
    Sevir : I didn't even see that, thanks bud

0 comments:

Post a Comment