<img id="imgCaptcha" src="SandCaptcha.aspx?CHA=0azSeOdr7S7gTkFxtL6/5B6h2vj+naZnDR5jl/dvceoJHNXcooHfP2MkoWxPRVWvdK7NJHckH" style="height:60px;width:160px;">
(function() {
'use strict';
function atualiza() {
document.querySelector('.captcha').addEventListener('click', function() {
alert('yolo');
var id = imgCaptcha();
this.setAttribute('src', 'SandCaptcha.aspx?id=' + id);
});
I tried this but it doesn't work.
How can I reload this captcha image without reloading page, with the help of JavaScript?
Try adding?t='+new Date().getTime()
to your setAttribute. this.setAttribute('src', 'SandCaptcha.aspx?id=' + id + '?t='+new Date().getTime());
This should force the image to reload instead of using the cache.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.