Re: A timed refresh ?

From: Date: Sun, 02 Sep 2001 12:38:34 +0000
Subject: Re: A timed refresh ?
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-12094@lists.php.net to get a copy of this message
"Dave Carrera" <dave@davecarrera.com> wrote in message news:EGENJHOKDODMKPOIBOMOGEALCBAA.dave@davecarrera.com... > I have an array of which shows an image in a place on my page which shows > the next on the list when the page refreshes, this works fine. > > What I want to do is have the image refresh on a 5 second timed interval. > > So: > > I have a list of images i.e..: > > image_1.gif > image_2.gif > image_3.gif > > Which I want to refresh every 5 seconds I would suggest using JavaScript for this; something like <html> <head> <script language="javascript"> <!-- img = 0; max_img = 0; delay = 5000; // 5 seconds imgnames = new array( 'image_1.gif', 'image_2.gif', 'image_3.gif' ); images = new array(); function preload() { var i = 0; for (name in imgnames) { images[i] = new Image(); images[i].src = name; i++; } max_img = i; } function start() { setInterval("replaceImage(document.images[abc])", delay); } function replaceImage(hImg) { if (++img >= max_img) img = 0; hImg.src = images[img].src; } --> </script> </head> <body onload='preload(); start();')> <img name='abc' src = 'image_1.gif'> </body> </html> (This is just off the top of my head; it is untested and probably not cross-browser compatible, but it should point you in the right direction).

« previous php.db (#12094) next »