How to detect if the user clicked the “back” button

后端 未结 5 623
说谎
说谎 2020-11-29 06:41

When the user goes history-back-1...how do I detect that? And then, alert \"the user clicked back!\"

Using binds (and jQuery preferably)

5条回答
  •  长情又很酷
    2020-11-29 07:11

    On the page you are looking at, you can add this piece of code to the onLoad event to move them back the page they were on.

    if(history.length>0)history.go(+1)
    

    If you want the alert then make it

    if(history.length>0)alert("the user clicked back!")
    

提交回复
热议问题