On a real estate website I'm working on I have a Contact Us form on the Property Details page where the user can click the Contact Us button, which will load the form in a modal dialog, an iframe loading the contact us form, fill in some details and send it off.
Once the form has been processed server side I have to emit JavaScript code from the server that calls the dialog close method and then redirects the user to a thank you page (If I did a simple redirect on the server the iframe would get the thank you page which I don't want).
The problem is in Chrome where if you hit the Browser's back button the contact form is quietly resubmitted.
Note: IE and Firefox don't have this issue at all.
I found the following links useful, but not the answer to my problem:
- https://productforums.google.com/forum/#!topic/chrome/J1KMARIIHW4
- https://code.google.com/p/chromium/issues/detail?id=263508 (this one seems very close to the behaviour I'm seeing - but it seems like a bug that has continually resurfaced over the last couple of years)
- Chrome executing all JS again on browser back button
We've tried various techniques to circumvent the issue in Chrome like hidden fields, insured cache is turned off, destroy the iframe before redirecting to the thank you page. Nothing it keeps resubmitting the form without even asking if you want to resubmit (not that it should be resubmitting at all)