refreshing webcam image in browser

tomciob

Limp Gawd
Joined
Apr 27, 2002
Messages
132
what is wrong with the refresh setting here, it does not update with a new image called 'cam'



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url= -->
<HTML><HEAD><TITLE> </TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<META content="MSHTML 6.00.2800.1276" name=GENERATOR></HEAD>
<BODY>


<CENTER><IMG id=pic src="cam"
name=pic></CENTER>



<script LANGUAGE="JavaScript">
<!--
function reloadImg()
{
uniq = new Date();
uniq = "?"+uniq.getTime();
newImage = document.all.imgToLoad.src;
index = newImage.indexOf("?", 0);
if (index > 0)
{
newImage = newImage.substr(0, index);
}
document.all.imgToLoad.src = newImage+uniq;
}
// -->
</script>





<script language="JavaScript">
<!--
var countDownInterval=7;
var countDownTime=countDownInterval;
function countDown()
{
--countDownTime;
if (countDownTime < 0)
{
countDownTime=countDownInterval;
}
document.all.countDownText.innerText = countDownTime;
setTimeout("countDown()", 1000);
}
// -->
</script>
Next Reload in <b id="countDownText">0</b> seconds
<script language="JavaScript">
<!--
setTimeout("countDown()", 1000);
// -->
</script>










</BODY></HTML>
 
edit: looked at your script.

you need to call reloadIMG() when your countdown hits < 0.

Code:
  if (countDownTime < 0)
{
countDownTime=countDownInterval;
reloadIMG();
}
document.all.countDownText.innerText = countDownTime;
setTimeout("countDown()", 1000);
}

also, your reloadimg() function doesnt seem to reload the image because it's not changing document.pic.src at all. Modify your script to have it affect the right image object.

--KK
 
I would skip the javascript and just use

<META HTTP-EQUIV="REFRESH" CONTENT = "5; URL=yourCamImagePage.htm">

easy enough
 
The meta method works also but is undesirable in cases where there are other things on the page that doesnt need to be reloaded every 10seconds. In the case of a plain web cam page though, the meta tag would probably be better. gg marshac

--KK
 
Even if there are other elements, just use an iframe, and load the page with the meta refresh (and webcam image) within the iframe.... that way the iframe can refresh forever without the entire page having to reload.
 
Back
Top