Fwd: Re: [thelist] image refresh not page refresh

John C Bullas (soton.ac.uk relay) jcbullas at nildram.co.uk
Thu Jan 15 03:18:34 CST 2004


>>
>>John,
>>
>>If I understand you correctly, you wish to reload just an image on a page
>>every few (perhaps 30) seconds?  If so, your best bet is to use JavaScript.

Yup


>>SetInterval will allow you to create a block of code that execute every x
>>milliseconds.
>>
>>Example:
>>
>>setInterval('reloadImage()', 30000);  // 30 seconds
>>
>>Then, the reloadImage should replace the image thusly:
>>
>>function reloadImage()
>>{
>>   img = document.getElementById('theimage');
>>   img.src = '/path/to/the/image/theimage.jpg?' + Math.random();
>>}
>>
>>The Math.random() appended to the end of the image filename ensure that the
>>browser will reload the image.
>>
>>HTH,
>>
>><><><><><><><><><><>
>>Joshua Olson

REPLY:

Will this in the HTML (all in the body) to replace the image tag work? not 
sure if the path is supposed to be a URL or an absolute "CGI style"
local reference?

<script type="text/javascript" language="JavaScript">
function reloadImage()
{
   img = document.getElementById('theimage');
   img.src = '\mail.soton.ac.uk\home\johnb\public_html\webcam\Pryme.jpg?' + 
Math.random();
}
</script>

<script type="text/javascript" language="JavaScript">
{
setInterval('reloadImage()', 30000); // 30 seconds
}
</script>


More information about the thelist mailing list