Home > Web Front-end > JS Tutorial > body text

How to keep the src of the image img unchanged and let the browser reload it_javascript skills

WBOY
Release: 2016-05-16 17:39:00
Original
2954 people have browsed it

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

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template