Click to See Complete Forum and Search --> : Image slideshow


Ninel
03-17-2003, 04:03 PM
I have a web page in which I want an image slideshow when the page loads.

I have the following code:

<SCRIPT LANGUAGE="JavaScript">
//set image paths
src = ["images/pic1.jpg", "images/pic2.bmp", "images/pic3.jpg"]

//set duration for each image
duration = 3;

ads=[]; ct=0;

function switchAd() {
var n=(ct+1)%src.length;
if (ads[n] && (ads[n].complete || ads
[n].complete==null))
{document["Ad_Image"].src = ads [ct=n].src;}
ads[n=(ct+1)%src.length] = new Image;
ads[n].src = src[n];
setTimeout("switchAd()",duration*1000);}

function doLink(){
} onload = function(){
if (document.images)
switchAd();}
</SCRIPT>

<A HREF="java script:doLink();" onMouseOut="status=''"><IMG NAME="Ad_Image" SRC="images/Pic1.jpg" BORDER=0 width="150" length="120"></A>

This works if the mouse moves over the pic.
How can I change this so that the slideshow begins when the page loads without any mouse interaction.

Thanks,
Ninel

khalidali63
03-17-2003, 04:15 PM
Take a look at this line
<A HREF="java script:doLink();"

in your code put the function doLink() in the onload event
your body tag should look like this

<body onload="switchAd();">

This hsould take care of it

Khalid

P.S
there is not checks for compatibal browsers.