javascript - Way to force image to reload from server - Stack Overflow

I've seen all of the other posts on similar issues with setAttribute() in IE, but can't seem

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 badges
Add a ment  | 

1 Answer 1

Reset to default 7

I'm pretty sure it will reliably reload your captcha image:

oImgElement.src = oImgElement.src + '?' + Math.random();

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744404574a4572564.html

相关推荐

  • javascript - Way to force image to reload from server - Stack Overflow

    I've seen all of the other posts on similar issues with setAttribute() in IE, but can't seem

    6天前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信