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

前端 未结 8 1481
感动是毒
感动是毒 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:43

    You can't. The browser doesn't send it's own ui events to the server. All you get are http requests and one looks pretty much like another. Maybe the clicked the back button or maybe they just retyped the last url in. Tell us what problems it's causing and we can help you adapt your project to work with the http protocol a little better.

提交回复
热议问题