View Full Version : Webcam refresh script...

08-26-2011, 06:24 PM
I was given this bit of code:

<img src="current.jpg" name="refresh" width="306" height="408">
<script language="JavaScript" type="text/javascript">
image = "current.jpg" //name of the image
function Reload() {
tmp = new Date();
tmp = "?"+tmp.getTime()
document.images["refresh"].src = image+tmp

// -->

to refresh a webcam image. I want to know what it means--how often is it set to refresh? I don't know javascript so I can't tell. Is it set to refresh whenever the image is new? or what? I would like to move away from my meta-refresh page-in-an-iframe method of refreshing my webcam if I can. My cam uploads a new image every 5 seconds. I need code that would allow the new image to be seen. Will this code do it? I tried it and it doesn't seem to refresh that often. So what does it do, and can it be tweaked?

Occam's Razor
08-26-2011, 09:33 PM
The refresh interval is set here:


That is in "ms" and not regular seconds so divide the number by 1000 to get seconds.

Basically, it refreshes once per second. To get a 5-second refresh just change 1000 to 5000.