Disable Browser Back Button Using Javascript
Today, we will explain to you how to disable browser back button using javascript. 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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | <!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: