Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Aug 2011
    Posts
    82
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Webcam refresh script...

    I was given this bit of code:

    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 
          setTimeout("Reload()",1000) 
          } 
          Reload(); 
    
          // --> 
          </script>
    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?

  • #2
    New to the CF scene
    Join Date
    Aug 2011
    Location
    USA
    Posts
    3
    Thanks
    1
    Thanked 1 Time in 1 Post
    The refresh interval is set here:

    Code:
    setTimeout("Reload()",1000)
    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.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •