Click to See Complete Forum and Search --> : time


sneezy
04-02-2003, 02:07 AM
var interval=3000; // change this value to change the speed, ie: 2000 = 2 seconds between slides

this is taken from my orginal script. Is it possible to set a different time for each slide on the page so therefore this work at different times?

Many Thanks

gil davis
04-02-2003, 06:04 AM
Assign a different interval for each slide. The easiest thing to do would be to use an array that contained the slide file name and the desired interval.

sneezy
04-02-2003, 08:16 AM
How would I do that ?

gil davis
04-02-2003, 08:42 AM
Oh, something like this:<script>
var imgAry = new Array();
imgAry[0] = new Image(); // you probably have a preload somewhere
imgAry[0].src = "some file name";
imgAry[0].delay = 3000;
imgAry[1] = new Image();
...
function nextSlide() {
document["slideshow"].src = imgAry[slide].src;
setTimeout("nextSlide()", imgAry[slide].delay);
slide = (slide + 1) % numSlides;
}Since you didn't post a link, it's hard to be specific.

sneezy
04-02-2003, 08:52 AM
Sorry same to have 2 meesages going at the moment theirs one on page 3 because at first I didn't know how to create 4 individual slide shows and now I would like to set 4 different time speeds but here is the orginal script.

Many Thanks

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>JavaScript Slide Show by Mike McGrath</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">

<!-- Step 1 : Copy this section and paste between the <HEAD> </HEAD> tags on your page -->
<SCRIPT type="text/javascript">
<!-- Original: Mike McGrath (mike_mcgrath@lineone.net) -------------------------------->
<!-- Web Site: http://website.lineone.net/~mike_mcgrath -------------------------------->
<!--

// preloader
var img=new Array();
img[0]=new Image(); img[0].src="java_picts/indexpict02.gif";
img[1]=new Image(); img[1].src="java_picts/indexpict03.gif";
img[2]=new Image(); img[2].src="java_picts/indexpict04.gif";

var interval=3000; // change this value to change the speed, ie: 2000 = 2 seconds between slides
var n=0;
var imgs = new Array("images/index_r3_c3.gif","java_picts/indexpict02.gif","java_picts/indexpict03.gif","java_picts/indexpict04.gif");
function rotate()
{
if(navigator.appName=="Netscape" && document.getElementById)
{
document.getElementById("p").src=imgs[n];
}
else document.images.p.src=imgs[n];
(n==(imgs.length-1))?n=0:n++;
setTimeout("rotate()",interval);
}
// -->
</SCRIPT>
<!-- Change the image filenames ("otis1.jpg", etc) to the names of YOUR image files ----->
<!-- Change the delay figure of 3000 to suit your prefence - 5000 would be 5 seconds. --->
<!-- End of Step 1 ---------------------------------------------------------------------->

</HEAD>
<BODY leftMargin="0" topMargin="0" onload="rotate()" marginwidth="0" marginheight="0">
<table width="790" cellspacing="0" cellpadding="0">
<tr>
<td width="3">_</td>
<td width="204">_</td>
<td width="575">_</td>
<td width="6">_</td>
</tr>
<tr>
<td>_</td>
<td><img height=249 alt=Slide src="images/index_r3_c3.gif" width=197 name="p" id="p"></td>
<td><img height=249 alt=Slide src="images/index_r3_c3.gif" width=197 name="p" id="p"></td>
<td>_</td>
</tr>
</table>
</BODY></HTML>

gil davis
04-02-2003, 09:04 AM
Sorry same to have 2 meesages going at the moment theirs one on page 3 because at first I didn't know how to create 4 individual slide shows and now I would like to set 4 different time speeds but here is the orginal script.That's what you get for starting a new thread on the same basic problem.img[0]=new Image(); img[0].src="java_picts/indexpict02.gif"; img[0].dly = 2000;
...
setTimeout("rotate()",img[n].dly);
...