I'm new to this, and stole/doctored my code from the "Ugly JavaScript
Handbook"
I have a slide show program.
First theres stuff to set up the array, and the time between slides
Then a function startIt()is defined
then a function stopIt()
Then two buttons, Start and Stop, which when pressed call the relevant
functions
When the page loads, you have to click the Start button to get the
slide show running, but I'd like it to start running straight away
without having to click.
I can't for the life of me figure this out.
I thought it was just a question of putting the line
startIt();
in the appropriate place.
Here's the whole of the code
Thanks
Tony
<HTML><HEAD>
<TITLE>Holiday</TITLE>
<SCRIPT LANGUAGE="JavaScript">
<!-- Hide from JavaScript-Impaired Browsers
var ctr=1;
var pics=17;
var speed=3500; // set initial
var ns="0123456789"; // number index
/* First, create a new array and then
create an image holder and load it
with the logo animation images. */
isn=new Array();
startIt()
for (i=1;i<=pics;i++){
isn[i]=new Image();
isn[i].src=i+".jpg";
}
startIt()
/* Next do the same for the number
images to display speed. */
nr=new Array();
for (i=0;i<=pics;i++){
nr[i]=new Image();
nr[i].src="nr/"+i+".jpg";
startIt()
}
function startIt(){
document.ugly.src=isn[ctr].src;
ctr=(ctr>(pics-2)?1:++ctr);
/* Here we put a "hook" on the
setTimeout() call by naming it.
This allows the clearTimeout()
call to know which one (there
might be others) to stop. */
tstop=setTimeout("startIt()",speed);
}
startIt()
function stopIt(){
clearTimeout(tstop);
}
startIt()
// End Hiding -->
</SCRIPT>
startIt()
</HEAD>
<BODY BGCOLOR="white"><CENTER>
<P><B>Ginny & Eva tour Europe</B>
<P><IMG SRC="5.jpg" height="350" NAME="ugly" BORDER="0">
<P><FORM>
<P><INPUT TYPE="button" NAME="b1" onClick="startIt()" VALUE=" Start
Slide Show">
startIt();
<INPUT TYPE="button" NAME="b2" onClick="stopIt()" VALUE=" Stop Slide
show">
</FORM>
startIt()
<P>Present delay (milliseconds):
<IMG SRC="nr/1.gif" WIDTH="7" HEIGHT="10" BORDER="0">
<IMG SRC="nr/0.gif" WIDTH="70" HEIGHT="10" BORDER="0">
<IMG SRC="nr/0.gif" WIDTH="70" HEIGHT="10" BORDER="0">
<IMG SRC="nr/0.gif" WIDTH="7" HEIGHT="10" BORDER="0">
startIt()
</BODY>
startIt()
</HTML>