How to block user from returning to the previous browser page

1

Is there a method that causes a user to not be able to return to the previous page?

It turns out that I have a contact form on which the person must fill out and that's it. It is not possible to return and fill again.

It's as if the browser tab created a new section, or something like that.

  

Is it possible to "lock" the option to return to the previous page?

    
asked by anonymous 04.11.2016 / 15:18

1 answer

2

This script will replace attempts to navigate forward and backward with the status of the current page.

history.pushState(null, null, document.URL);
window.addEventListener('popstate', function () {
    history.pushState(null, null, document.URL);
});
The pushState changes the referrer that is used in the HTTP header for XMLHttpRequest objects created after changing the state.

See more about.

Note that this code is not cross-browser , use it at your own risk.

UPDATE

The pushState method is compatible with

Chrome - 5 >
Firefox (Gecko) - 4.0 (2.0) >
Internet Explorer - 10 >
Opera - 11.50 >
Safari - 5.0 >
    
04.11.2016 / 15:32