|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
You eat, breathe and sleep innovation. Build your mobile intelligence with BlackBerry® experts this July. Register Today! |
|
#1
|
|||
|
|||
|
hey guys i need some help with this. I am trying to make each image fade in one after another. Eg the left image fades in, then the next the next.
I have written this simple script to do it, and if i check the activity log it has loaded the images, but by the time the page is loaded it is on the last image. So I cant get the timeout to work?? <script LANGUAGE="JavaScript"> <!-- if (document.images != null) { pic0 = new Image();pic0.src = "two0.gif"; pic1 = new Image();pic1.src = "two1.gif"; pic2 = new Image();pic2.src = "two2.gif"; pic3 = new Image();pic3.src = "two3.gif"; pic4 = new Image();pic4.src = "two4.gif"; pic5 = new Image();pic5.src = "two0.gif"; pic6 = new Image();pic6.src = "two1.gif"; pic7 = new Image();pic7.src = "two2.gif"; pic8 = new Image();pic8.src = "two3.gif"; pic9 = new Image();pic9.src = "two4.gif"; pic10 = new Image();pic10.src = "two0.gif"; pic11 = new Image();pic11.src = "two1.gif"; pic12 = new Image();pic12.src = "two2.gif"; pic13 = new Image();pic13.src = "two3.gif"; pic14 = new Image();pic14.src = "two4.gif"; } function fadeIn() { for(i=0; i<15; i++) { if (i < 5) { document.images['pic1'].src = eval('pic' + i + ".src"); } if (i < 10) { document.images['pic2'].src = eval('pic' + i + ".src"); } if (i < 15) { document.images['pic3'].src = eval('pic' + i + ".src"); } } setTimeout('fadeIn()',50); } //--> </SCRIPT> </HEAD> <BODY onload="fadeIn()"> <A HREF="#"><IMG SRC="two0.gif" NAME="pic1" BORDER=0 WIDTH=21 HEIGHT=21></A> <A HREF="#"><IMG SRC="two0.gif" NAME="pic2" BORDER=0 WIDTH=21 HEIGHT=21></A> <A HREF="#"><IMG SRC="two0.gif" NAME="pic3" BORDER=0 WIDTH=21 HEIGHT=21></A> <A HREF="#"><IMG SRC="two0.gif" NAME="pic4" BORDER=0 WIDTH=21 HEIGHT=21></A> <A HREF="#"><IMG SRC="two0.gif" NAME="pic5" BORDER=0 WIDTH=21 HEIGHT=21></A> |
|
#2
|
||||
|
||||
|
timeout
Are you sure the conditional testing is correct?
if i = 1 it is < 5 and it is also < 10 and it is also < 15. Anyway you have setTimeout('fadeIn()',50); 50 is 50 microseconds not 50 seconds. In other words 1/20th of a second. Since the for loop makes 15 passes it reaches the last image in 3/4 of a second. If you want 50 seconds use 5000 instead. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > JavaScript Development > Need Timeout help please |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|