How to disable browser back button using Jquery?

By Hardik Savani | April 10, 2019 | Category : Javascript jQuery

How can we disable browser forward and back button using jquery or javascript that is lead topic. we can use window.history.pushState for restrict back button of browser in jquery. we can disable back button in browser using jquery in php or any mvc framework like laravel, codeigniter etc.

Sometime we need to restrict back button function in your browser because of security. so no one can access that page with back button.

I will give you simple example to disable browser back button in js, so you can run js code in your local system and see it. Just see bellow example:


<!DOCTYPE html>



<title>How to disable browser back button using Jquery? -</title>

<script type="text/javascript" src=""></script>



<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);





I hope it can help you....

Hardik Savani
My name is Hardik Savani. I'm a full-stack developer, entrepreneur and owner of Aatman Infotech. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.
Follow Me: Github Twitter
***Do you want me hire for your Project Work? Then Contact US.

We are Recommending you: