Hey all,
I'm trying to use setInterval() to refresh an image continuously. I opted to use setInterval() outside the function it calls versus using setTimeout() in the function because I do not want the function execution time to effect the refresh rate to dramatically.
Either way, my test page is very basic:
Code:
<html>
<head>
</head>
<body>
<a href="#webprocesses"><font color="darkgreen" size=+1><b>Web Procs</b></font></a>
<table align="center">
<tr>
<td valign="top"><a name="webprocesses"></a></td>
<td>
<table>
<tr><td align="center"><font color="darkred">Web Server Processes</font></td></tr>
<tr><td><a href="webprocgraph.html"><img name="WsP"></a></td></tr>
<tr><td><br></td></tr>
</table>
</td>
</tr>
</table>
<SCRIPT language="JavaScript" type="text/javascript">
Start();
setInterval("Start()", 10000);
function Start()
{
document.images.WsP.src='/cgi-bin/GraphingPortal.cgi?file=webprocesses2H.xml';
}
</SCRIPT>
<body>
</html>
I've researched many sites and these forums. I'm almost positive that the syntax is correct. For some reason, it will only reload once, then it just stops doing it. For the heck of it I tried using setTimeout() in Start() and had the same results. I get the initial load, but thats it. I know the script has to be located at the bottom as the image object has to be defined before I can use document.image.
Anyone have any ideas what might cause this?
Matt
*EDIT* I just found it works fine in IE6. It is not working in Firefox. Unfortunatly this will be used in a predominantly Firefox shop.
*EDIT #2* So upon further testing I found something very strange. I open the page in Firefox and it does not work. I open a second instance of the page in a new firefox window or tab and bingo, it works like a champ, as does the original instance still open. I close one and the other stops working. How the heck does this happen?!