How to find whether the user clicks browser back button or Refresh button

前端 未结 8 1320
感动是毒
感动是毒 2021-02-07 12:59

I need to find whether the user clicking the browser back button or Refresh button.

I need to redirect the page to Error page when he clicks the back or refresh button.

8条回答
  •  太阳男子
    2021-02-07 13:45

    We did it in Java/Struts1 by putting a property on the submit button. If the submit button was clicked the button text would be sent in the property in the ActionForm. If the user refreshed the information the value wasn't set, so we knew the user had not clicked the button. In this case where the property was empty, we went back and rendered the first page of the pageflow. YMMV in ASP.Net.

提交回复
热议问题