Refresh image on click not working as planned...
So I'm trying to refresh an image when it's clicked, but I've a small problem...
Here's the snippet I'm using:
Code:
onclick="document.getElementById('weather').src='http://sirocco.accuweather.com/nx_mosaic_160x120_public/sir/inmsirfl_.gif?rand='+Math.random();"
This is attached to the IMG tag I'm using. When the page first loads, the image displays just like I want it to, but when I click the image to refresh it, I get a broken image. I'm assuming it has something to do with the way accuweather stores their images because if I try to copy/paste the link of the 'refreshed' image, I get a 404 page. If I try the code WITHOUT the "?rand=+Math.random()", the image doesn't refresh (natrually, as the computer has no reason to reload something in cache). Is there a javascript solution that would perhaps delete the existing image from the cache and then re-download it?
bryceowen, August 5th, 2009 08:06 PM
Bookmarks