Home >Web Front-end >JS Tutorial >How to keep the src of the image img unchanged and let the browser reload it_javascript skills
JavaScript splices a ? and JavaScript object new Date().getTime() millisecond value into queryString after the src attribute of this img tag, which can prevent it from being cached.
The image address src remains unchanged. In this case, let the browser reload the image
In fact, when the src does not change, the browser directly reads the cache
Solution:
var img_src = 'http://www.ilsea.net/images/seagull.jpg?t=' Math.random();
Splice a random number into the image address in this way, and use js to reassign the src of img, okay