Detect if page is load from back button

后端 未结 7 860
无人及你
无人及你 2021-02-06 23:07

Is there any way to detect if current page came from back button?

I want to load data from cookie only if current page came from back button.

7条回答
  •  旧巷少年郎
    2021-02-06 23:39

    Basically, you can't because of browser restrictions. HTML5 history API, the onpopstate event will be triggered when navigating to back page. But this will fire even if u use application navigation.

    alternative solution refer - How to Detect Browser Back Button event - Cross Browser

提交回复
热议问题