- Messages
- 8,631
- Location
- Thomasville, GA
For you programming gurus out there:
For several years, I've been displaying my shop cam on my website during times I'm out here. Now, I would like to display two cams on the same page and have them refresh occasionally. I found some Java code a few years ago that worked well for one image but have not been able to figure out how to make it work for two images.
Here's the code I've been using:
<script>
var imgFresh = new Image();
var imgNow;
var imgSrc;
function errHandler()
{
defaultStatus = "Failed";
}
function loadHandler()
{
defaultStatus = "Loading ...";
document.images[imgSrc].src = imgNow;
}
function living(srcName,imgFile)
{
imgSrc = srcName;
var now = new Date() ; now = "?"+ now.getTime();
imgNow = imgFile + now;
imgFresh.src = imgNow;
imgFresh.onload=loadHandler;
imgFresh.onerror=errHandler;
setTimeout("living('" + srcName + "','" + imgFile + "')",5000);
}
</script>
I've tried duplicating portions of the script and using subscripts to differentiate them. What should I be doing to the script? Or, is there a better way to do what I want.
Thanks for your help.
PS: Yeah, yeah. I know this is a woodworking forum but there seem to be some sharp computer folks on here.
By the way, the software I'm using to control the cameras and FTP the jpg files is iSpy.
For several years, I've been displaying my shop cam on my website during times I'm out here. Now, I would like to display two cams on the same page and have them refresh occasionally. I found some Java code a few years ago that worked well for one image but have not been able to figure out how to make it work for two images.
Here's the code I've been using:
<script>
var imgFresh = new Image();
var imgNow;
var imgSrc;
function errHandler()
{
defaultStatus = "Failed";
}
function loadHandler()
{
defaultStatus = "Loading ...";
document.images[imgSrc].src = imgNow;
}
function living(srcName,imgFile)
{
imgSrc = srcName;
var now = new Date() ; now = "?"+ now.getTime();
imgNow = imgFile + now;
imgFresh.src = imgNow;
imgFresh.onload=loadHandler;
imgFresh.onerror=errHandler;
setTimeout("living('" + srcName + "','" + imgFile + "')",5000);
}
</script>
I've tried duplicating portions of the script and using subscripts to differentiate them. What should I be doing to the script? Or, is there a better way to do what I want.
Thanks for your help.
PS: Yeah, yeah. I know this is a woodworking forum but there seem to be some sharp computer folks on here.
By the way, the software I'm using to control the cameras and FTP the jpg files is iSpy.