Firefox won't change image source

后端 未结 2 1164
说谎
说谎 2021-01-27 04:44

I\'m trying to change an image in JavaScript+Prototype by changing the \"src\" attribute of the element. It works fine in IE, but not in Firefox. I don\'t get any errors and the

相关标签:
2条回答
  • 2021-01-27 05:18

    Cant figure out what is wrong, but I believe its possible to do a:

    image.src = "../images/icons/icon_minus.gif";
    

    BTW, is the image path absolutely correct?

    0 讨论(0)
  • 2021-01-27 05:22

    This function works fine in all browsers(chrome,Firefox,IE,Edge,...):

    function recaptcha() {
      $("#captcha-img").attr('src', "");
      setTimeout(function(){
           $("#captcha-img").attr('src', "captcha?"+new Date().getTime());
      }, 0);
     }
    

    The important point is generating new URL which forces FF and IE to re-render the image.

    0 讨论(0)
提交回复
热议问题