Browser Back button

I am having a requirement where i want to catch browser back button event and show them feedback message and also dont allow them to navigate.


Some of the solutions i got are this:-

1.

window.history.pushState(null, "", window.location.href);

window.onpopstate = function () {

    window.history.pushState(null, "", window.location.href);

};

2.

history.pushState(null, null, location.href);

    window.onpopstate = function () {

        history.go(1);

    };


But my application is little different.

I am having 3 web blocks in same page which i am displaying as per visibility control.

This solutions are directly refreshing my page, i dont want that.


Please help me out with this!

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.