javascriptbrowserdouble-submit-prevention

Double submit after page reload


I have a following scenario:

First webpage has a form which does submit to the server. Server responds with second page. The second page has a hidden form which is being submitted using javascript on form load, it redirects user to an external site.

My question is: Is it possible for the user to double submit the second form doing form submit on the first page twice (within one page view of the first page)?

The question relates to how this would work in practice, I don't need alternative scenarios.


Solution

  • I'll ignore the fact that practise shouldn't be used as a production solution.

    What you're asking cannot occur if the users browser has not executed the second form's onLoad() javascript event.

    As with any solution like this you can never be 100% sure how a client browser behaves when two events occur near simultaneously, but I would say in most cases a browser will not execute the onLoad() event twice.

    What you do need to be careful of is the browser's back button behaviour. That could definitely cause a resubmission.