Today, we will explain to you how to disable browser back button using jquery. if you want to disable your browser back button then you can use the window.history.pushState for jquery.
Many online banks limit their users to clicking the “Refresh” or “Back” button, as this can interfere with or stop a transaction in progress. This can cause the bank or customer to lose valuable data. you can disable the browser back button using the below code. so you can see the below code.
<!DOCTYPE html> <html> <head> <title>disable browser back button using jquery - XpertPhp</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> </head> <body> <h1>Click the browser back button</h1> </body> <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> </html>
Please follow and like us: