My personal joomla based site has a custom module showing an image from a webcam. The module has some javascript that refreshes the image in that module every ten seconds and works perfectly.
The problem with adding a second webcam module is it uses the same javascript code so overrides the first cam and two identical images are shown instead of two different images.
How to change the code to differentiate between the two modules?
The code I'm using;
<div align="center"><img src="mypath/cam_1.jpg" name="refresh" height="240" width="320" />
<script type="text/javascript">
var t = 10 // interval in seconds
image = "mypath/cam_1.jpg" //name of the image
function Start() {
tmp = new Date();
tmp = "?"+tmp.getTime()
document.images["refresh"].src = image+tmp
setTimeout("Start()", t*1000)
}
Start();
</script>
</div>
The second webcam module code is identical except for the image which is named cam_2.jpg
You can see what's happening if you click on the site link below.
The problem with adding a second webcam module is it uses the same javascript code so overrides the first cam and two identical images are shown instead of two different images.
How to change the code to differentiate between the two modules?
The code I'm using;
<div align="center"><img src="mypath/cam_1.jpg" name="refresh" height="240" width="320" />
<script type="text/javascript">
var t = 10 // interval in seconds
image = "mypath/cam_1.jpg" //name of the image
function Start() {
tmp = new Date();
tmp = "?"+tmp.getTime()
document.images["refresh"].src = image+tmp
setTimeout("Start()", t*1000)
}
Start();
</script>
</div>
The second webcam module code is identical except for the image which is named cam_2.jpg
You can see what's happening if you click on the site link below.
Comment