Rafay
Rafay

Reputation: 24265

GIF not animating on page load

I am trying to create a splash page (I know, I tried to talk him out of it) that displays the logo animation (.gif) and a button to enter website. So far, I have a div that contains the image, however, the image is not animating as one would expect. Surprisingly, the image animates every time in Internet Explorer. How do I go about solving this?

I have tried injecting the image after page load with jQuery to no avail.

$(document).ready(function() {
    $("#splash").append("<img src='img/logo_splash.gif'>");
})

Upvotes: 0

Views: 8601

Answers (1)

James Hill
James Hill

Reputation: 61812

Try appending a random number to your GIF URL. Chrome and Firefox prevent a GIF from playing more than once.

$(document).ready(function() {
    $("#splash").append("<img src='img/logo_splash.gif?"+ Math.random() + "'/>");
})

Upvotes: 7

Related Questions