1. When you click on a button, the picture in the field to change the picture
<span style= "Cursor:hand" onclick= "Reflush (); return false;" > can not see clearly </span>
<script>
function Reflush ()
{
document.getElementById (randimg). src= "/servlet/createvalidatenum";
}
</script>
2. Notes
"Servlet/createvalidatenum" is a Java-written servlet. The servlet is printing out the picture
3. The problems that arose
The picture under IE6 is modified normally, but not refreshed under IE7 and Firefox
4. Situation Analysis
If the new picture is not the same as the old picture address, the effect will come out. That is: The picture has changed.
But like the "Captcha" feature. The address of the old and new pictures is the same.
In view of the above, it is suspected that the image address is the same, causing the browser to read the cache automatically.
5. How to Solve
Change the JavaScript to this way:
document.getElementById (randimg). src= "/servlet/createvalidatenum?" +math.random ();
That is: Each access address is not the same, because there is a random number. So the problem is solved
jquery Gets the src attribute by the method: $ ("#image"). attr ("src");
Modify the SRC attribute value: $ ("#image"). attr ("src", "image/1/gif");
------------
This method is feasible and I have tested it. Of course, I'm using jquery.
var src = "/servlet/createvalidatenum?" +math.random ();
$ ("#img_id"). attr ("src", src_v);