防止浏览器和警告,严格的方式需要

I need to prevent the user to switch back to previous pages strictly. I show you example coding as follows:

 <html>
 <head>
 <script type="text/javascript">   

/* prevent back  */
window.history.forward();
    function prevent()
    {
window.history.forward(); 
    }


/* warning on unload */
window.onbeforeunload = function (e) { var message = 'Are you sure ?'; if (typeof e == 'undefined') { e = window.event; } if (e) { e.returnValue = message; } return message; }


 </script>
 </head>
    <body onload="prevent();" onpageshow="if (event.persisted) prevent();" onunload="">
        <!--content here-->
    <a href="in.html">in</a>
    </body>
 </html>

The above page have link to another page, if i click back on that second page, it come back to this first page and showing warning and then move to second page;

Second page:

<a href="hello.html">hello</a>

I added warning script for some reason.

Now, what i need exactly is. When prevent back working, warning script should not work.

1.When user unload a page, should show warning script 2.when prevent back function unload the page, should not show warning script

Is there any way possible to disable going back from a page in all the way, any strict way? the above coding is not much strict. it will move forward on getting back.

Thanks.

Yeah, boi.

But seriously, this baby don't got back

page 1

<html>
    <head>
         <title>if you go, don't come back</title>
     </head>
     <body>
            <!--content here-->
         <a href="pageofnoreturn.html#noBack">in</a>
    </body>
</html>

pageofnoreturn.html

<html>
    <head>
         <title>Stay put, or else</title>
     </head>
     <body>
         <h1>welcome to purgatory</h1>
        <script>
            if (location.hash == '#noBack') {
                history.pushState(null, '', '#sit');
                //whatever hashes that suit your project
                window.onhashchange = function() {
                    if (location.hash == '#noBack') {
                        history.pushState(null, '', '#sit');
                    }
                }
            }
        </script>
    </body>
</html>