Detect if the user has used the back button

Tom picture Tom · Mar 23, 2010 · Viewed 8.7k times · Source

My webpage runs a javascript function when the page is loaded. However, I don't want the function to run if the user comes back to this page using the back button. How can I prevent this using javascript?

$(document).ready(function(){
  // Do not run this function if the user has arrived here using the back button  
  RefreshThePage();
});

Answer

matpol picture matpol · Mar 23, 2010

I'd have thought that using cookies is the easiest way to do this