But another way you can do it is by inserting the following code into the page that you don’t wish to support the ability to go back to:
How does it work?
go(1), makes the browser go forward to the next page in the browser history. The first time you visit a page, your browser history does not have a page to go to, so go(1) does nothing. But if you try and go back to a page on which the above code exists, then because you have a page in history, go(1) works and takes you back to the page that you were on. Simple and effective.
Note: I came across this solution on the Internet and cant find the link anymore.