Animation 重置webp动画,使其从第1帧开始播放,然后重新启动动画webp
已经针对gif文件讨论了此问题。 以下是webp文件不适用的内容。剧本以Animation 重置webp动画,使其从第1帧开始播放,然后重新启动动画webp,animation,reset,webp,Animation,Reset,Webp,已经针对gif文件讨论了此问题。 以下是webp文件不适用的内容。剧本以 var animatedWebpImg = document.getElementById('idOfTheWebpInsideAnImgElement'); 第一次失败的尝试是 animatedWebpImg.style.display = "none"; setTimeout(function() { animatedWebpImg.style.display = "block&quo
var animatedWebpImg = document.getElementById('idOfTheWebpInsideAnImgElement');
第一次失败的尝试是
animatedWebpImg.style.display = "none";
setTimeout(function() { animatedWebpImg.style.display = "block"; },100);
其次,我用完全相同的逻辑尝试了removeChild()
和appendChild()
,但也没有成功
最后我接近了,但是没有成功
var srcOfTheImg = animatedWebpImg.src;
animatedWebpImg.src = ""; // empty and then back to original
animatedWebpImg.src = srcOfTheImg;
这就是成功的原因
var srcOfTheImg = animatedWebpImg.src;
animatedWebpImg.src = "data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==";
setTimeout(function () { animatedWebpImg.src = srcOfTheImg; },100);
这意味着,我没有将src清空为空,而是用一个透明的像素填充它——一个不可见的东西。使用
animatedWebpImg.src=“”代码>对我也有效,超时似乎是关键。