gpt4 book ai didi

javascript - 动画 gif 在 Firefox 中不重新启动(示例)

转载 作者:搜寻专家 更新时间:2023-10-31 21:50:06 24 4
gpt4 key购买 nike

问题描述:

在许多情况下,动画 gif 在 Firefox 中似乎无法正常重启。这个问题我只在 Mozilla 中遇到过,没有其他浏览器。

例如,为什么this总是重新启动它,但是 this才不是?在后者中,gif 显然被缓存并在后台永远循环,所以当您调用 .show() 时,它会出现在动画中间的某个随机点。

我怎样才能实现我在第二个 fiddle 中尝试做的事情,并在每次隐藏它时强制 gif 重新启动?不,我不想每次都重新下载整个 gif,因此将 '?random=' + Date.now() 附加到图像不是解决方案。

代码来自Link #1 :

$('#still, #animated').click(function() {
animated.attr('src', "");
animated.attr('src', srcToGif);
});

代码来自Link #2 :

$('#still, #animated').click(function() {
if (!clicked) {
clicked = 1;
animated.attr('src', "");
animated.attr('src', srcToGif);
animated.show();
setTimeout(function() {
animated.hide();
clicked = 0;
}, 9500);
}
});

最佳答案

替换

animated.attr('src', "");

animated.removeAttribute('src');

适用于 Firefox 30。假设单词 animated 是一个普通的、非 jquery 特定的 img 引用。

我一般不做js库,因为我想有控制权。由于库的体积,缩小通常是虚幻的,而且当确实发生异常时,很难进行故障排除。

关于javascript - 动画 gif 在 Firefox 中不重新启动(示例),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22331655/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com