Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

How to Disable an Back Button using JavaScript & HTML?

In this article, we will discuss how to disable the back button using HTML and Java Script. There are many methods to disable the browser's back button that are most popular, and they work in any situation. 

It is possible to add Code to the previous or first page to make the browser move forward repeatedly to ensure that when a user attempts to return to the previous page, the browser will return him precisely the same way. 

This article will examine how to develop a Javascript function that will make it impossible for the user to go back to the previous or previous page.

How to disable browser's back button with JavaScript?



To disable web browsers’ back button, run the following code. This is the code for the current HTML page,

Example 1.

First create a firstpage.html

   
      Disable Browser Back Button
     
     
   
   
   
      Next Page
   
   
      $(document).ready(function() {
         function disablePrev() { window.history.forward() }
         window.onload = disablePrev();
         window.onpageshow = function(evt) { if (evt.persisted) disableBack() }
      });
   

The following is the code for newpage.html

   
        Blocking Back Button
        using javascript
   
     

This is second page

         On this page, back button
         functionality is disabled.
     


More example coming soon. That’s it for today. If you have any queries, please feel free to ask in the comment section

Thank you for reading. Happy Coding..!! 🙂

Share the post

How to Disable an Back Button using JavaScript & HTML?

×

Subscribe to Madlr.com - Jio 4g, Free Recharge Tricks, Mobile Reviews, Coupons Codes, Blogging, Seo, Hacking

Get updates delivered right to your inbox!

Thank you for your subscription

×