2014-12-02 21 views
0

我有一個在IE和Chrome中正常工作的進度條。當你點擊一個鏈接或輸入按鈕提交時,通過JQuery調用進度欄。但Firefox中的行爲並不是我期待的。如果點擊前一頁,加載欄仍然在Firefox中運行

這是我的腳本:

$("a, input[type=submit]").click(// http://heartcode.robertpataki.com/canvasloader/ 
    function() { 
    if ($(this).attr('target') == '_blank' || $(this).hasClass("noloadingbar")) { 
    } 
    else { 
     var cl = new CanvasLoader('canvasloader-container'); 
     cl.setDiameter(65); // default is 40 
     cl.setDensity(50); // default is 40 
     cl.setRange(0.8); // default is 1.3 
     cl.setFPS(29); // default is 24 
     cl.show(); // Hidden by default 

     // This bit is only for positioning - not necessary 
     var loaderObj = document.getElementById("canvasLoader"); 
     loaderObj.style.position = "absolute"; 
     loaderObj.style["top"] = cl.getDiameter() * -0.5 + "px"; 
     loaderObj.style["left"] = cl.getDiameter() * -0.5 + "px"; 
    } 
    } 
) 

當我在Firefox中點擊一個鏈接,進度「欄」正在加載,就像在IE和Chrome。但是當我點擊上一個按鈕(上一頁)時,Firefox中的進度欄​​再次啓動。

我怎樣才能確保這不會發生?

+0

這不僅是這個進度 '欄'。如果您放置$(「div.row」).append(「

測試,仍然站在

」),它仍然可以在前一頁中看到... – 2014-12-02 12:12:34

回答

0

這是在離開頁面後告訴de進度條停止的技巧。

$(window).unload(function(){ 
    c1.stop(); 
}); 

將是:

$(document).on('click','a, input[type=submit]',function(){ // Aan de hand van een klik de functie oproepen 
    if ($(this).attr('target') == '_blank' || $(this).hasClass("noloadingbar")) {} 
    else { 
    var cl = new CanvasLoader('canvasloader-container'); 
    cl.show(); // Hidden by default 

    $(window).unload(function(){ // Anders stop Firefox niet als je pagina terug gaat 
     c1.stop(); 
    }); 
    } 
}); 
相關問題