Image animation from a predefined array of images.

I would like to know how could I create a page that contains an image .When a mouse moves over it , it's source keeps changing from a predefined array of images.
When the mouse moves out, its source returns to the first image of the array.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Hi sherihan.

Here's an example, is it what you're looking for?


<title>Rotating Banner Example</title>

<script language="javascript" type="text/javascript">

var index = 0;
var cont = false;
var banners = new Array("", "", "");

function rotate() {
      if (cont) {
          if (index == banners.length) index = 0;
            document.getElementById('the_banner').src = banners[index];
            setTimeout('rotate()', 500);

function start() {
    cont = true;

function end() {
      cont = false;
      document.getElementById('the_banner').src = banners[0];


<style type="text/css">



<body onload="">
<img id="the_banner" onmouseover="start();" onmouseout="end();" src="" />
<br />
The banner above will change every 1/2 a second when you have the mouse over the image.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
<script >
var index = 0;
var frameSrc = new Array(

function preload(){
 frameArr=new Array
 for (i=0;i<frameSrc.length;i++)
 {frameArr[i]=new Image

function nextFrame() {

<body onload="preload()">
<img id="theFilm" src=""
index++ in the  mouseout can be removed
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

sherihan, Why have you accepted an answer that does not work?
GwynforWebCommented: IE that is.
sherihanAuthor Commented:
hi GwyforWeb,
why do u say that the accepted coad doesn't work.
I tested it and it works correctly.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Languages and Standards

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.