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

2
  • 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. developer.mozilla.org/en-US/docs/Web/Events/beforeunload Commented Jul 21, 2017 at 15:56
  • thanks. i "clearInterval" "onBeforeUnload". it works. Commented Jul 24, 2017 at 14:41

1 Answer 1

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"> 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.