Force reload an image using javascript

When we try to reload the image using JavaScript it does not work due to the browser caching the image.

The workaround for this is to append a "#" at the end of the image path ie say the image is
<img src="http://www.blogger.com/captcha.php" id="captcha" /><a href="javascript://document.getElementById().src+='#'">Reload</a>

This way we fool the browser to think its a different image and the browser reloads the image. Simple eh?

Comments

Post a Comment

Popular Posts