Animated gifs do not restart in Firefox (with examples)

Description of the problem:

Animated gifs do not display properly in Firefox under many circumstances. This is a problem that I only experience in Mozilla and without another browser.

For example, why does this work to always restart it, but is it not? In the latter case, gif is explicitly cached and forever looped in the background, so when you call .show (), it will appear at some random point in the middle of the animation.

How can I achieve what I am trying to do in the second script and make the gif reload every time I hide it? And no, I don’t want to reload the whole gif every time, so adding '?random=' + Date.now()to the image is not a solution.

Code Link # 1 :

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

Code from 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);
    }
});
+4
source share
1 answer

Replace

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

from

animated.removeAttribute('src');

Works for me in Firefox 30. Assuming the word animatedis a regular, non-jquery-specific link img.

js-, . - , , .

0

Source: https://habr.com/ru/post/1531210/


All Articles