clock  Mon - Sun 8.00 AM - 8.00 PM
fb
instagram
play store
pinterest

Disable Back Button in Browser Using jQuery

writter  Sumit Dey Sarkar
Date  26 Aug 2022
Language  JQuery
Disable Back Button in Browser Using jQuery

Disable Back Button in Browser Using jQuery

In this tutorial we will learn how to disable back button in browser using jQuery.

Here we will use window.history.pushState for restrict back button of browser in jQuery.

let's see the example - 

How to disable back button in browser using jQuery

<!DOCTYPE html>
<html>

<head>
  <title>Disable Back Button in Browser Using jQuery</title>
  <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
</head>

<body>

  <button>click on browser back button</button>

  <script type="text/javascript">
    $(document).ready(function () {
      window.history.pushState(null, "", window.location.href);
      window.onpopstate = function () {
        window.history.pushState(null, "", window.location.href);
      };
    });
  </script>

</body>

</html>