Track when user hits back button on the browser

前端 未结 7 1203
陌清茗
陌清茗 2020-11-28 10:56

Is it possible to detect when the user clicks on the browser\'s back button?

I have an Ajax application and if I can detect when the user clicks on the back button I

7条回答
  •  情歌与酒
    2020-11-28 11:07

    I set a variable $wasPosted in $_SESSION with value false.

    All my posts go via the same php file, and set $wasPosted to true.

    All header(location:) requests are preceded by setting $wasPosted to true.

    If $wasPosted is false then the page was loaded after use of the backward or forward buttons.

提交回复
热议问题