Friday, May 24, 2019

Restrict Browser Back button

history.pushState(null, null, location.href);
    window.onpopstate = function () {
        history.go(1);
    };

Use the above code to restrict going to the back page from the current page.

This piece of code comes very handy when you are working on dynamics portals and you have logic where you should not allow users to navigate to back page.

No comments:

Post a Comment