GIF动画不能在页面加载 [英] GIF not animating on page load

查看:144
本文介绍了GIF动画不能在页面加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个初始页面(我知道,我试图说服他的话),显示标志动画(.gif注意)和一个按钮进入网站。到目前为止,我有一个 DIV 包含图像,但图像不动画正如人们所期望。出人意料的是,图像动画在Internet Explorer中每一次。我该如何去解决呢?

我试图用jQuery页面加载后的图像注入无济于事。

  $(文件)。就绪(函数(){
    $(#扑通)追加(< IMG SRC =IMG / logo_splash.gif'>中);
})


解决方案

尝试附加一个随机数到你的GIF的网址。 Chrome和Firefox prevent从不止​​一次打多了GIF。

  $(文件)。就绪(函数(){
    $(#扑通)追加(< IMG SRC =IMG / logo_splash.gif?+的Math.random()+'/>中);
})

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'>");
})

解决方案

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() + "'/>");
})

这篇关于GIF动画不能在页面加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆