I have a server that, when POST
is sent to /generate
, it generates "stuff" in an HTML page. The page itself uses JavaScript window.history.replaceState(null, null, window.location.href)
so that the user can reload the page (using GET
) and see the same data without the browser asking if it should resend POST
information.
The page also has a "Regenerate" button that sends POST
back to /generate
to regenerate new information. Unfortunately this results in a new point in navigation history, so that the user can hit the browser "Back" button to go back to the previous version of the /generate
page. I don't want this behavior. I want the page to be able to "replace" the current page with the new generated contents without creating a new point in navigation history.
(I am well aware that a more modern approach would be to asynchronously query the server using Ajax and update the page dynamically. I imagine that is what will be done in an upcoming release. I'm asking for a quick workaround for the current release of this product.)
Is there a way that I can have a page send a POST
so that it doesn't result in a new point in navigation history? The JavaScript on the page can detect if regeneration occurred, but I can't find out how to remove the current navigation state, only replace it. Ideally I would like to POST
without creating a new point in navigation history at all.
I don't see any way this is possible, but I thought I would run it by the community to see if someone knew a trick. Thanks.
from Prevent generation of browser history on `POST` to self
No comments:
Post a Comment