0

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

user3083618
  • 270
  • 1
  • 4
  • 16
  • 1
    I would use a `onBeforeUnload` listener. It's more natural than capturing a `click` event, though you may need to change stuff to handle which button they clicked. The reason I suggest `onBeforeUnload` is because I doubt it will cause you the same issues with event. Worth a shot. https://developer.mozilla.org/en-US/docs/Web/Events/beforeunload – Leeish Jul 21 '17 at 15:56
  • thanks. i "clearInterval" "onBeforeUnload". it works. – user3083618 Jul 24 '17 at 14:41

1 Answers1

0

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">
Sambuccid
  • 166
  • 2
  • 4