I've seen all of the other posts on similar issues with setAttribute() in IE, but can't seem to get any of the workarounds to, er, work (specifically for the src attribute of an img element.
The example:
function reloadCaptcha(sImgElementId) {
var oImgElement = document.getElementById(sImgElementId);
oImgElement.setAttribute('src', oImgElement.src);
return false;
}
And the img element:
<img id="nlc" name="nlc" src="/inc_captcha.asp" onClick="javascript:reloadCaptcha('nlc'); return false;" />
It just reloads the src. Works like a charm in Chrome and FF. Nada in IE.
How can I make this work in IE?
I've seen all of the other posts on similar issues with setAttribute() in IE, but can't seem to get any of the workarounds to, er, work (specifically for the src attribute of an img element.
The example:
function reloadCaptcha(sImgElementId) {
var oImgElement = document.getElementById(sImgElementId);
oImgElement.setAttribute('src', oImgElement.src);
return false;
}
And the img element:
<img id="nlc" name="nlc" src="/inc_captcha.asp" onClick="javascript:reloadCaptcha('nlc'); return false;" />
It just reloads the src. Works like a charm in Chrome and FF. Nada in IE.
How can I make this work in IE?
Share Improve this question edited Jan 24, 2013 at 3:57 jfriend00 709k104 gold badges1k silver badges1k bronze badges asked Jan 24, 2013 at 3:48 GWRGWR 1,9885 gold badges31 silver badges47 bronze badges1 Answer
Reset to default 7I'm pretty sure it will reliably reload your captcha image:
oImgElement.src = oImgElement.src + '?' + Math.random();