强制firefox重新加载img.src更改后的图像 [英] Force firefox to reload image after img.src change
问题描述
我正在修改一些画布上的图片,然后将此图片的src设置为新的base64编码图片。
img。 src = changeColor(img);
changeColor返回base64编码图片:
return canvas.toDataURL();
Chrome和Opera在src更改后刷新图像,但firefox不!
我还检查了FireBug的图像元素,它显示新的src和新的图像!
我已经尝试添加数据到URL,但呃.. 。这是一个base64编码的图像,而不是一个url,所以它完全打破了我的图片。
我有任何方式强制重新加载图像或通过javascript禁用firefox缓存? / p>
更新:
我也试图设置image.src ='';在changeColor函数中。
它在chrome中工作,但在firefox ...图片消失,并且不会再出现时,我设置新的base64值。
我没有使用图像数据,但这是一个类似的问题,当没有重新加载,当src变量没有改变:
image.src =;
setTimeout(function(){
image.src = //新图像src
},0);
I'm modifying some images on canvas and then setting src of this images to new base64 coded pictures.
img.src = changeColor(img);
changeColor returns base64 coded image:
return canvas.toDataURL();
Chrome and Opera are refreshing images after src change, but firefox don't! I also inspected the image element by FireBug, and it shows new src and new image!
I have already tried to add Data to URL but uhh... this is a base64 coded image, not an url, so it breaks my pictures totally.
I there any way to force reload images or disable firefox cache via javascript?
UPDATE: I have also tried to set image.src=''; in changeColor function. It works in chrome, but in firefox... picture disappear, and do not appear again when i set new base64 value.
I am not using image data, but this worked for a similar issue where FF was not reloading when the src variable didn't change:
image.src = "";
setTimeout(function(){
image.src = //the new image src
}, 0);
这篇关于强制firefox重新加载img.src更改后的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!