July 22, 2009

How can I force a reload of an image from the server if the image already exists in the browser's cache?

Q416 How can I force a reload of an image from the server if the image already exists in the browser's cache?

By adding a different search string value after the image href. The following reloads the image from the server every 10 seconds:



<---script language="JavaScript">
function reloadImage() {
var now = new Date();
if (document.images) {
document.images.myImageName.src = 'picture.gif?' + now.getTime();
}
setTimeout('reloadImage()',10000);
}
setTimeout('reloadImage()',10000); //-->





Source: http://www.irt.org/script/416.htm

No comments:

Post a Comment