PHP help

Anyone have any code to refresh the webcam image on a page every so many minutes??? I would also like to figure out a way to stop the image at sunset with the last daytime image and restart at sunrise?? just some ideas!! :lol:

I use this Java script to refresh an image every 30 seconds on my site:

<p align="center"><img name="refresh" src="yourimagename.gif" alt="yourimage">
    <SCRIPT language=JavaScript type=text/javascript>
      <!--
      var t = 30 // interval in seconds
      image = "yourimagename.gif" //name of the image
      function Start() {
      tmp = new Date();
      tmp = "?"+tmp.getTime()
      document.images["refresh"].src = image+tmp
      setTimeout("Start()", t*1000)
      }
      Start();
      // -->
      </SCRIPT>

      Image will update once a minute.</p>

It only refreshes the image and not the whole screen. :wink:

Thanks I’ll give it a try!! :smiley:

Is there a way to set a timer so people can’t sit on a page all day?? I know they will be able to refresh the page but that’s ok… :slight_smile:

I use a refresh script for the image that only works 180 times, then stops

<script type="text/javascript">
var maxnum = 180;
var reloadcount = 0;
function reloadImage() {
    var now = new Date();
    if (document.images) {
        document.images.myPull.src = 'http://saratogawx.dyndns.org:18080/netcam.php?' + now.getTime();
    }
    if(reloadcount < maxnum-1) {
		setTimeout('reloadImage()',1000); 
	} else {  
	  var element = document.getElementById("finmsg");
       if (element) {
         element.style.color = "black";
	   }
    }
	reloadcount++;
}

setTimeout('reloadImage()',1000);
</script>

and the image markup is


<img src="http://saratogawx.dyndns.org:18080/netcam.php?nocache" id="myPull" alt="Netcam facing North-East" width="320" height="240" />

<span id="finmsg" style="color: white;"><strong>The time limit has expired .. reload page to restart live image stream.</strong></span>

It shows 180 pulls of the netcam, then stops and reveals the “time limit expired” message (which was hidden by being white text on white background, changed to black text by the JavaScript.

Hope this helps…

Best regards,
Ken

Hey Thanks a bunch Ken I’m using part of your script already to refresh the imageso it looks like I can add part of this to that to make the page refresh which I have set for every 1 minute so I will shorten up the time!!?

if you are using the webcam upload in WD you can set to only upload during day time only
so that the last image is the sunset image

will that work even on local files Brian I don’t upload???

Hey Ken any Idea what to change to fix this?? I tried the “<” but the script stopped working??

Line 199, Column 20: character “<” is the first character of a delimiter but occurred as data if(reloadcount < maxnum-1) {
:email:

This message may appear in several cases:

[quote author=n7xrd link=topic=54700.msg439255#msg439255 date=1328404352]
Hey Ken any Idea what to change to fix this?? I tried the “<” but the script stopped working??

Line 199, Column 20: character “<” is the first character of a delimiter but occurred as data if(reloadcount < maxnum-1) {
:email:

This message may appear in several cases:

yes I am here’s the link…
http://www.n7xrd.tzo.com/wdisplay/web/webcam.php

Sometimes the validator gets confused and tries to parse JavaScript as HTML.

You can avoid that with inline scripts by changing the script to have ‘CDATA’ start/end tags at the start of the script and end of the script like this

<script type="text/javascript">
// <![CDATA[

... javascript here ...

// ]]>
</script>

See if that works…

:smiley: Ken your a genius WOW wish I knew half you did with this scripting stuff I’ve been trying to fix one error on my main page for 2 weeks now and still can’t figure it out I’ve tried everything!!! #-o Thanks so much hopefully when things get a little better I can show my thanks to all who have helped me out with the support and writing of these scripts!! Any way too use this or a similar script for the wxradio page to allow say maybe 10
and stop the stream??