Hello,
I've got a small issue with a image code of mine. It's a random image code. But here comes the part I'm having a problem with, I've customized it to allow me to have two images at the same time. However, they are both linked together. The reason for this is because the images are big so cutting them in two pieces would make the loading quicker. However... It's not working as it should, Here's a link to the style, so you can see the problem (Refresh a couple of times):
http://rarewarecentral.com/forums/index.php?styleid=108
I have checked several times, all the images do exist on my server, all the links are valid ... So It's probably something wrong with my code. Since I'm not any good at javascript at all I'm seeking help.
This is the code:
Code:
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin Random Logo In Header Script
var theImages = new Array() // do not change this
<!-- Edit the url images to match yours
<!-- Edit the url images to match yours
theImages[0] = 'http://rarewarecentral.com/forums/images/btc/logo1-1.png'
theImages[1] = 'http://rarewarecentral.com/forums/images/btc/logo2-1.png'
theImages[2] = 'http://rarewarecentral.com/forums/images/btc/logo3-1.png'
theImages[3] = 'http://rarewarecentral.com/forums/images/btc/logo4-1.png'
theImages[4] = 'http://rarewarecentral.com/forums/images/btc/logo5-1.png'
theImages[5] = 'http://rarewarecentral.com/forums/images/btc/logo6-1.png'
theImages[6] = 'http://rarewarecentral.com/forums/images/btc/logo7-1.png'
theImages[7] = 'http://rarewarecentral.com/forums/images/btc/logo8-1.png'
theImages[8] = 'http://rarewarecentral.com/forums/images/btc/logo9-1.png'
theImages[9] = 'http://rarewarecentral.com/forums/images/btc/logo10-1.png'
theImages[10] = 'http://rarewarecentral.com/forums/images/btc/logo11-1.png'
theImages[11] = 'http://rarewarecentral.com/forums/images/btc/logo12-1.png'
theImages[12] = 'http://rarewarecentral.com/forums/images/btc/logo13-1.png'
theImages[13] = 'http://rarewarecentral.com/forums/images/btc/logo14-1.png'
theImages[14] = 'http://rarewarecentral.com/forums/images/btc/logo15-1.png'
theImages[15] = 'http://rarewarecentral.com/forums/images/btc/logo16-1.png'
theImages[16] = 'http://rarewarecentral.com/forums/images/btc/logo1-2.png'
theImages[17] = 'http://rarewarecentral.com/forums/images/btc/logo2-2.png'
theImages[18] = 'http://rarewarecentral.com/forums/images/btc/logo3-2.png'
theImages[19] = 'http://rarewarecentral.com/forums/images/btc/logo4-2.png'
theImages[20] = 'http://rarewarecentral.com/forums/images/btc/logo5-2.png'
theImages[21] = 'http://rarewarecentral.com/forums/images/btc/logo6-2.png'
theImages[22] = 'http://rarewarecentral.com/forums/images/btc/logo7-2.png'
theImages[23] = 'http://rarewarecentral.com/forums/images/btc/logo8-2.png'
theImages[24] = 'http://rarewarecentral.com/forums/images/btc/logo9-2.png'
theImages[25] = 'http://rarewarecentral.com/forums/images/btc/logo10-2.png'
theImages[26] = 'http://rarewarecentral.com/forums/images/btc/logo11-2.png'
theImages[27] = 'http://rarewarecentral.com/forums/images/btc/logo12-2.png'
theImages[28] = 'http://rarewarecentral.com/forums/images/btc/logo13-2.png'
theImages[29] = 'http://rarewarecentral.com/forums/images/btc/logo14-2.png'
theImages[30] = 'http://rarewarecentral.com/forums/images/btc/logo15-2.png'
theImages[31] = 'http://rarewarecentral.com/forums/images/btc/logo16-2.png'
var j = 0
var p = theImages.length;
var preBuffer = new Array()
for (i = 0; i < p; i++){
preBuffer[i] = new Image()
preBuffer[i].src = theImages[i]
}
var whichImage = Math.round(Math.random()*(p-5));
function showImage(){
document.write('<img src="'+theImages[whichImage]+'"/></a><img src="'+theImages[whichImage+16]+'"/></a></div>');
}
// End -->
</script>
<center>
<SCRIPT LANGUAGE="JavaScript">
showImage();
</script>
</center>
I believe the problem should be within:
Quote:
function showImage(){
document.write('<img src="'+theImages[whichImage]+'"/></a><img src="'+theImages[whichImage+16]+'"/></a></div>');
}
|
I think this has some effect, can somebody tell me the proper number I should use for this?
Code:
var whichImage = Math.round(Math.random()*(p-5));
Please help. Thanks.