检测用户是否使用了后退按钮

问题描述:

我的网页在加载页面时运行javascript函数。但是,如果用户使用后退按钮返回此页面,我不希望该功能运行。如何使用javascript来阻止这种情况?

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();
});


我原以为使用cookies是最简单的这样做的方式

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