Loading Image On Client Side few times per second

admin

Administrator
Staff member
I am trying to load a specific image few times per second. The same image is updated or replaced constantly using another software. The images are being loaded fine, but sometime I see a red X. This means that I am loading an invalid image.

How do I make sure that I don't load the invalid image?

Here is the code:

<html>

<head>
<script language="JavaScript"> <!--
//document.images.theHiddenImg.style.display='None';
function showImg() {
document.images.myImageName=document.images.theHiddenImg;
}
function reloadImage() {
var now = new Date();
if (document.images) {
//document.images.myImageName.src = 'picture.gif?' + now.getTime();
//document.images.myImageName.src = 'http://www.google.com/images/logo.gif?' + now.getTime();
//document.images.myImageName.src = 'http://john/google.com-logo.gif?' + now.getTime();
//try { ... } catch (e) { alert("hi"); }
document.images.theHiddenImg.src = 'http://john/frame.jpg?' + now.getTime();
}
setTimeout('reloadImage()',0.0333);
}
setTimeout('reloadImage()',0.0333);
--> </script>
</head>

<body>
<img src=http://www.webdeveloper.com/forum/archive/index.php/"http://john/frame.jpg" name="myImageName">
<img src="http://john/frame.jpg" name="theHiddenImg" OnLoad="showImg();">
<!--
<img src="http://john/frame.jpg" name="myImageName" OnError="reloadImage()">
<img src="http://john/google.com-logo.gif" name="myImageName">
<img src="http://www.ebay.com/">
<img src="http://users.snip.net/%7Esaponara/01-07.c03.rot.jpg" name="myImageName">
-->

</body>

</html>
 
Top