Could some one please tell me how I would refresh one image every time 2 minutes? Can some please show me a source code, I've been trying for ages.
If it's the server that changes the images you cannot use javascript for that. You have to use a sheduled task or cron job. Why not use javascript instead. Name your images image1.gif, image2.gif etc... and do something like set timer; count to 20 seconds; if i < max image number img.src = image.gif add 1 to ielse image src = image.gifstart over or just create an animated gif that changes every 20 seconds
This will do it. Just change both instances of "image.png" to whatever your image name will be. First I set up a function that uses the DOM to specify the image. (The image would change onscreen if it were a different filename in the JS function.) Then, in the body of the document, I set up a counter that calls the function every 180000 milliseconds, or every 2 minutes. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Test</title> <script type="text/javascript"> function imgRefresh() { document.getElementById("changeMe").src = "image.png"; } </script> </head> <body> <img src="image.png" id="changeMe" /> <script type="text/javascript"> setInterval('imgRefresh()', 180000); </script> </body> </html> Code (markup):
Thank you le_gber and KatieK, I'm going to try out those methods now. I'm not entirely sure my server changes the images, I don't think so.