简体   繁体   中英

Firefox prevoius page button reload setInterval

I have a link to a page. The loading is slow and on click event i show a progress bar and run a timing loop with random text. I do this with setInterval. I change the text every 8 seconds.

When the loading is completed, the browser shows the new page. I don't clear Interval because i think the new page doesn't share anything with the previous page.

But, if i click on the previous button on Firefox, it seems to remember the there was an intervarl and it runs it again. In Chrome, the prevoius button seems to reload the page and the interval there isn't. Why Firefox has this behavoiur?

You can see the page here: http://www.demo.tinnservice.com:8090/

I set the interval on click to "Ricerca Avanzata"

This is the html tag

<a class="linkSlow" data-action="archivio" href="/archivio">Ricerca avanzata</a>

This is the javascript code:

function smokeInTheEyes(element){           
            $("body").css("position","relative");
            $("#wait-overlay").addClass("in");      
            var frasi=frasiObj[element.data("action")];
            var i=0;            
            setTimeout(function(){$("#frase").text(frasi[i]).show("400");},1000)            
            var timer=setInterval(function(){   
                i+=1;
                console.log(i);
                if(i==frasi.length){i=0;}
                $("#frase").hide("400",function(){$("#frase").text(frasi[i]).show("400")});                             
             }, 8000);          
    }
    $(".linkSlow").click(function(e){                           
                    smokeInTheEyes($(this));            
                }); 

PS: Frasi is an object with two or more array of strings. The data-action attribute on the clicked tag tell me which array i use to display the random text

Possible ducplicate: Force Firefox to Reload Page on Back Button

This is the accepted answer created by jknair :

add this between your HEAD tags

<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="-1">

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM