I use the following JS for a simple but effective image randomizer:
That works great to randomly pull one of the images listed. I'm curious, though... Would anyone like to take a crack at expanding that code so that a matching background image is pulled into that image's cell?
Basically what I'm getting at is that I have a cell with the random image code applied to it, but the cell expands horizontally the fill the browser window. Because each of the main images is a finite width, I'm left with a rather large and ugly gaping hole to the right of the image when a user expands their browser. To work around that, I'd like to create a repeating background image for that cell that would give the appearance of the image continuing to the right. Problem is, I have no idea what the code would be to match up each random "main" image with its background image, so that when the main one is randomly displayed the background image would match.
I'd be ridiculously grateful if anyone could help me out here.
Thanks,
m19
Code:
<SCRIPT LANGUAGE="JavaScript">
<!-- Hide from old browsers
iArray=new Array(
"images/index_image1.jpg",
"images/index_image2.jpg",
"images/index_image3");
ri=Math.floor(iArray.length*Math.random());
ri='<IMG SRC="'+ iArray[ri]+ '" BORDER=0>';
// end hiding --></SCRIPT>
Code:
<SCRIPT language="JavaScript">
<!--
document.write(ri);
// -->
</SCRIPT>
That works great to randomly pull one of the images listed. I'm curious, though... Would anyone like to take a crack at expanding that code so that a matching background image is pulled into that image's cell?
Basically what I'm getting at is that I have a cell with the random image code applied to it, but the cell expands horizontally the fill the browser window. Because each of the main images is a finite width, I'm left with a rather large and ugly gaping hole to the right of the image when a user expands their browser. To work around that, I'd like to create a repeating background image for that cell that would give the appearance of the image continuing to the right. Problem is, I have no idea what the code would be to match up each random "main" image with its background image, so that when the main one is randomly displayed the background image would match.
I'd be ridiculously grateful if anyone could help me out here.
Thanks,
m19