How do I remove a page from the browser history?

前端 未结 8 1678
孤独总比滥情好
孤独总比滥情好 2021-02-07 11:21

I have an have an ASP.Net page which contains a button. This Page contains a ServerSide Paypal button.

When pushed my server does various clever things on the back end a

相关标签:
8条回答
  • 2021-02-07 11:34

    Perhaps you could set a cookie before submitting the form.

    When the page is loaded, check for the existence of that cookie (meaning the form was already submitted). If found, instead of automatically submitting the form, automatically go back (window.history.back()) again.

    0 讨论(0)
  • 2021-02-07 11:38

    A useful Hint for some might be this...

    window.history.go(-2);
    

    particularly in the advent of a load failure warning popup.

    0 讨论(0)
  • 2021-02-07 11:41

    I'm not sure if you can do this easily with PayPal integration, but the "Post / Redirect / Get" pattern can be used to address this problem

    0 讨论(0)
  • 2021-02-07 11:42
    protected void Page_Load(object sender, EventArgs e)
    
        {
    
            Page.RegisterClientScriptBlock("", "<script>if(history.length>0)history.go(+1);</script>");
    
        }
    
    0 讨论(0)
  • 2021-02-07 11:43

    As a web application, you'll never have full control of the user's browser. Even if there was a way to instruct the browser to not store the page in history, which I doubt, you can't be sure it'll work. For example, a clever user could tweak an open-source browser to store every page in history, no matter what.

    I think you should try to approach the problem from another angle. You could, for example, detect that it's the same form which is being forwarded and not send it to paypal the second time. The important thing is to do it server-side.

    0 讨论(0)
  • 2021-02-07 11:44

    You could simply programme your page not to submit, or to do something / navigate somewhere else, if window.referer is the Paypal page you are trying to avoid invoking a second time.

    0 讨论(0)
提交回复
热议问题