Having images swap on the Home Page at random

A

AshdownRoses

We have one main image on our home page. I'd like to have it rotate among
3-4 different JPEGs eacht time our customers go the home page. It can be at
random. I've tried working with behaviours but it does not seem to provide
for this. At least not that I can discern from the limited on-line help
available.
 
M

Murray

Simple.

Put this in the head of the page -

<script type="text/javascript">
<!--
function displayRandomImage(imageName,array){
document.images[imageName].src=array[new Date().getTime()%array.length];
}
urls=["images/cs1.jpg","images/cs2.jpg","images/cs3.jpg","images/cs4.jpg"]

//-->
</script>

(adjust the urls line to list the pathnames of the image files you want to
use)

then make the body tag like this (preserving other content already there, if
necessary) -

<body onLoad="displayRandomImage('yourimagename',urls)" ...>

where "yourimagename" is replaced with the HTML name of the image that you
want randomly selected.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top