I am building a site where anyone in management can access the security cams in the different stores. I have built using iframes so that the manager can choose which store they want. Once they choose the store, I want the page to refresh every 6 seconds but error out after 3 minutes. This will keep from streaming data continuously.
So here is what I have, but something isn't right
<title>Store #1901(low-rez)</title>
<center><font color ="blue">Store 1901 (<b>Medium</b> / <a href="tiny.html">Small</a>)</center>
<iframe src="cam1.html" width="380" height="295" frameborder="0" >
</iframe>
<iframe src="cam2.html" width="380" height="295" frameborder="0" >
</iframe>
<iframe src="cam3.html" width="380" height="295" frameborder="0" >
</iframe>
<iframe src="cam4.html" width="380" height="295" frameborder="0" >
</iframe>
<iframe src="cam5.html" width="380" height="295" frameborder="0" >
</iframe>
<iframe src="cam6.html" width="380" height="295" frameborder="0" >
</iframe>
<iframe src="cam7.html" width="380" height="295" frameborder="0" >
</iframe>
<iframe src="cam8.html" width="380" height="295" frameborder="0" >
</iframe>
<iframe src="cam10.html" width="380" height="295" frameborder="0" >
</iframe>
<script type="text/javascript">
var intervalID = 0;
function windowOnInitialize()
{
intervalID = setInterval("refresh()", 6000);
//alert("we were called");
}
var counter = 0;
function refresh()
{
//alert("we got to if statement");
if (counter < 50)
{
counter++;
//alert(counter);
document.getElementById("theId").src="small.html" + Math.random();
}
else
{
//alert("");
alert("Your Time is Up");
clearInterval(intervalID);
}
}
</script>
<body onload="windowOnInitialize()">
<img id="theId" src="small.html" />
I have tried the script above and below the iframe section and it isn't working either place. I am sorry if this is a repeated question or rather elementary, I am just learning to code. I have always worked network and not scripting.
The
setInterval
function expects a function as the first parameter. You have passed a string "refresh()". So, change the lineintervalID = setInterval("refresh()", 6000);
to pass the function instead -intervalID = setInterval(refresh, 6000);
.setInterval