1. When you click on a button, the picture in the field to change the picture
<span" style= "Cursor:hand"
Onclick= "Reflush (); return false;" > Unclear </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");
The above jquery modification image src attribute, the picture does not load the problem solution is small series to share to everybody's content, hoped can give everybody a reference, also hoped that everybody supports the cloud habitat community.