Prevent Form resubmission upon hitting back button

前端 未结 8 2008
无人及你
无人及你 2020-12-03 05:17

I have searched many posts here and elsewhere but can\'t seem to find a solution to my problem. I have a page which displays database entries: database.php. These entries c

8条回答
  •  -上瘾入骨i
    2020-12-03 05:38

    I used the answer at How do I detect if a user has got to a page using the back button? to detect whether or not the visit was triggered by a browser's back button click, and then if that was the case, I used JavaScript to reload the page. When the page is reloaded, my code already handles the corresponding validations to make sure that the form is never submitted twice. The important part in my case was forcing the page reload when the form was revisited after clicking the browser's back button. This is my code in the URL where I wanted to apply this validation:

    
    

提交回复
热议问题