2012-02-27 52 views
0

我正在使用它來啓動一個gif圖像計數器,以從3向下設置動畫。在所有瀏覽器上,除了Firefox 10工作正常,但在Firefox上它經常跳過3和直接從2Firefox10上的GIF隨機行爲

$('#counter-gif').attr('src', $('#counter-gif').attr('src')); 

任何想法,爲什麼這不能正常工作在Firefox上?謝謝

我正在使用該行代碼,因爲計數器是一個Ajax的成功方法,我運行多次,每次我需要重新啓動計數器並重新設置src導致重新啓動動畫。感謝

+2

所以你改變圖像的src本身?我對你試圖做什麼感到困惑。 – j08691 2012-02-27 17:11:35

+0

yes ..以這種方式gif的動畫重新啓動 – 2012-02-27 17:49:29

+0

我不知道是否因爲它是星期一,但你的問題對我來說很模糊。也許如果你發佈了其他代碼或者jsFiddle,你會得到更多的幫助。 – j08691 2012-02-27 17:52:36

回答

0

你應該在onload事件啓動計時器:

var img = new Image(); 
img.onload = function() { setTimeout("doSomething();", 3000); } 
img src="somegif.gif"; 

然而,這是根據我自己的假設你正在試圖做的是什麼。你沒有正確解釋。您的示例代碼集是gif的源代碼...本身的源代碼。因此,代碼的lince沒有做任何事情。

0

這是所有相關代碼:

success: function (data) { // after ajax 
    $('#counter-gif').attr('src', $('#counter-gif').attr('src')); 
    // this one starts the counter, but on firefox it starts from 2 not from 3, it is like it takes more to load the gif until it starts the animation 
    // bunch of unrelated code that treats the response 
}