如何在加载网站上运行加载动画?

时间:2016-01-21 17:36:45

标签: jquery html canvas jquery-animate loading

我通过此website创建此template。在这个网站必须加载网站显示加载。但是在加载我的网站时会收到错误:

  

无法加载图片

我缝了main.js文件,发现这段代码运行了这条消息。我在ff调试器中调试了这段代码但是没有解决。

Jquery代码:

// Preloader function
var cSpeed = 7;
var cWidth = 75;
var cHeight = 75;
var cTotalFrames = 8;
var cFrameWidth = 75;
var cImageSrc = '/images/sprites.gif';

var cImageTimeout = false;

function startAnimation() {

    document.getElementById('loaderImage').innerHTML = '<canvas id="canvas" width="' + cWidth + '" height="' + cHeight + '"><p>Your browser does not support the canvas element.</p></canvas>';

    //FPS = Math.round(100/(maxSpeed+2-speed));
    FPS = Math.round(100 / cSpeed);
    SECONDS_BETWEEN_FRAMES = 1 / FPS;
    g_GameObjectManager = null;
    g_run = genImage;

    g_run.width = cTotalFrames * cFrameWidth;
    genImage.onload = function () { cImageTimeout = setTimeout(fun, 0) };
    initCanvas();
}


function imageLoader(s, fun)//Pre-loads the sprites image
{
    clearTimeout(cImageTimeout);
    cImageTimeout = 0;
    genImage = new Image();
    genImage.onload = function () { cImageTimeout = setTimeout(fun, 0) };
    genImage.onerror = new Function('alert(\'Could not load the image\')');
    genImage.src = s;
}

//The following code starts the animation
new imageLoader(cImageSrc, 'startAnimation()');

我尝试保存这个gif图像,但我不能这样做。我的网站上没有sprites.gif图像。如何解决这个问题?

1 个答案:

答案 0 :(得分:1)

sprites.gif文件在sprites.gif

下载并上传到“/ images”目录。基本上你丢失了那个文件,当插件试图到达它时,404页面会发生302重定向。亲自看看:Page redirection because of missing file