View Single Post
Posts: 105 | Thanked: 48 times | Joined on Aug 2008
#8
Originally Posted by s2k View Post
I setup a simple JS function that causes a page refresh that shows the image every second. It works fne on PC. On NIT it runs for a a few seconds then stops as if the browser times outthe script, click the screen and it reactivates.

Anyone know how to prevent thsi from hapening, ie so it doesn't stop the JS refresh?
instead of refreshing the page, only refresh the image element. Here's how:
Code:
<html>
<head>
    <title>Untitled Page</title>
    <script type="text/javascript">
        function grabImage() {
            var imgFrm = document.getElementById('imageframe');
            var img = document.createElement("img");
            img.setAttribute('src', 'http://77.46.140.219/axis-cgi/mjpg/video.cgi?resolution=CIF&dummy=1234987014475');
            imgFrm.removeChild(imgFrm.firstChild);
            imgFrm.appendChild(img);
            setTimeout(grabImage, 10000);
        }
    </script>
</head>
<body onload="grabImage();">

<div id="imageframe"><img /></div>

</body>
</html>
NOTE: if you have to refresh the image, it's not really a mjpeg stream. It's just an image that get's updated at an interval. an mjpg stream should update itself without any JS in firefox on the Desktop or on the NIT's browser.

Last edited by MattZTexasu; 2009-02-18 at 20:45.