One possible reason for this issue could be Bug 129986 - "Cached Gif animations don't reset on reload." For more details, you can refer to the following link:
A similar problem seems to exist on the nasa.gov website with Firefox as well:
The gif animation plays about 4 times before stopping. Simply refreshing the page (F5
) does not resolve the issue. However, manually refreshing the cache (CRTL + F5
) seems to work.
I conducted a test using the code below in Firefox and the gif continued playing without any interruptions:
var img = new Image();
src = '../images/rt2/728x90_Animated_bg_2x.gif';
img.src=src;
setInterval(function(){
t=new Date().getTime();
$("img").attr("src", src+'?'+t);
},5000);
Edit:
I initially tried your approach but encountered the same issue (image was not displaying). The alternative method below worked successfully for me in Firefox:
var img = new Image();
src = '../images/rt2/728x90_Animated_bg_2x.gif' + '?a=' + Math.random();
img.src=src;
$('img').css('background-image',"url("+img.src+")");