The page detection method appeared using the back button

I made a way to display a loading indicator at the bottom of the page when I clicked a link.

When someone clicks the back button, he does not refresh the contents of the page, thereby showing the loading area.

Is there a way to determine if a page appeared from a redirect to launch a method to remove the loading indicator?

Kind:

function cameFromeBackButton(){ //hide loading indicator } 

OR is this a way to stop the back button and start the method instead? So:

 function backButtonClicked(){ //do stuff instead of going back } 

EDIT: This is pretty much called the area

 $('.link').click(function(){ //make loading area $('container').append(loadingAreaString) //grab the href and goto page window.location.href = $(this).attr('href'); return false }) 
+6
source share
1 answer

You can transfer some token from the server and store it in a cookie or local storage. When the stored token is different from the token embedded in the page, this means that the page was loaded from the server, if the values ​​are equal, it means that the page was sent from the cache (or from the "Back" button).

+1
source

All Articles