Image Slideshow

liunx

Guest
I am using the following code for an image slideshow:<br />
<br />
<body BGCOLOR="#000000" text="#CCCCCC" link="#CC9933" vlink="#999966" alink="#FFCC33" onload="doLink"><br />
<br />
<table border="0" cellpadding="0" cellspacing="0" width="100%"><br />
<tr><br />
<td><br />
<SCRIPT LANGUAGE="JavaScript"><br />
<!--<br />
//set image paths<br />
src = <!-- m --><a class="postlink" href="http://www.htmlforums.com/archive/index.php/">http://www.htmlforums.com/archive/index.php/</a><!-- m -->["images/Pic1.jpg", "images/Pic2.bmp", "images/Pic3.jpg"]<br />
//set duration for each image<br />
duration = 2; <br />
ads=[]; ct=0;<br />
function switchAd() <br />
{<br />
var n=(ct+1)%src.length;<br />
if (ads[n] && (ads[n].complete || ads <br />
[n].complete==null)) <br />
{<br />
document["Ad_Image"].src = <!-- m --><a class="postlink" href="http://www.htmlforums.com/archive/index.php/ads">http://www.htmlforums.com/archive/index.php/ads</a><!-- m -->[ct=n].src;<br />
}<br />
ads[n=(ct+1)%src.length] = new Image;<br />
ads[n].src = <!-- m --><a class="postlink" href="http://www.htmlforums.com/archive/index.php/src">http://www.htmlforums.com/archive/index.php/src</a><!-- m -->[n];<br />
setTimeout("switchAd()",duration*600);<br />
}<br />
function doLink(){<br />
} onload = function(){<br />
if (document.images)<br />
switchAd();<br />
}<br />
//--><br />
</SCRIPT><br />
<br />
Although the images do change at some point, they don't begin changing when the page just loads.<br />
Is there something that I need to change in the code to have the images flip as soon as the page loads?<br />
<br />
Thanks,<br />
Ninel<!--content-->By the way...Here's the web site:<br />
<!-- w --><a class="postlink" href="http://www.monarchmedical.com">www.monarchmedical.com</a><!-- w --><!--content-->I'm using IE6 and they did begin to change as soon as the page was loaded. I think that the onLoad event of the BODY element isn't triggered until everything on the page is loaded. But if you want them to start as soon as the script is read into the browser, I guess you could just remove the onLoad event, and put <SCRIPT type="text/javascript">doLink();</SCRIPT> somewhere. But maybe you'd need to change the doLink() a bit, I don't know.. I'm not a JS master, but that code looks strange to me.. Looks like just an empty function.. But it works somehow ;) Personally I'd be happy with the onLoad event, as you can be certain that all the images used in the slideshow also are loaded then.<!--content-->Heja Sverige, Rydberg! :)<!--content-->The question, and the answer from Rydberg look startingly familiar.<br />
<br />
Did I already answer this a few days ago somewhere in this forum?<br />
<br />
Like in: <!-- m --><a class="postlink" href="http://www.htmlforums.com/showthread.php?s=&threadid=22687">http://www.htmlforums.com/showthread.ph ... adid=22687</a><!-- m --><!--content-->Hahaha, that's a bit amusing giz. :D<!--content-->
 
Back
Top